我正在学习颤振,并且遵循一个教程,我准确地复制了他的代码,但是由于某些原因,我在我的代码中遇到了这个错误,该错误声明如下
class categoryMealsScreen extends StatelessWidget {
static const routeName = '/category-meal';
@override
Widget build(BuildContext context) {
final routeArgs =
ModalRoute.of(context)!.settings.arguments as Map<String, String>;
final categoryTitle = routeArgs['title'];
final categoryId = routeArgs['id'];
final categoryMeals = DUMMY_MEALS.where((meal) {
return meal.categories.contains(categoryId);
}).toList;
return Scaffold(
appBar: AppBar(
title: Text(categoryTitle!),
),
body: ListView.builder(
itemBuilder: (ctx, index) {
return Text(categoryTitle);
},
**itemCount: categoryMeals.length,**
),
);
}
}发布于 2022-01-14 17:20:56
将toList更改为toList()。
final categoryMeals = DUMMY_MEALS.where((meal) {
return meal.categories.contains(categoryId);
}).toList;https://stackoverflow.com/questions/70714262
复制相似问题