【发布时间】:2021-10-24 13:40:15
【问题描述】:
我收到上述错误(问题),代码如下:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('DeliMeals')),
body: GridView(
children: DUMMY_CATEGORIES
.map((categoryData) => CategoryItem( //getting
categoryData.title, //the error
categoryData.color, //here
))
.toList(),
虚拟数据
const DUMMY_CATEGORIES = const [
Category(
id: 'c1',
title: 'Italian',
color: Colors.purple,
),
Category(
id: 'c2',
title: 'Quick & Easy',
color: Colors.red,
),
];
我只是在学习一个教程。导师没有得到错误。 :(
【问题讨论】:
-
也请分享 CategoryItem 代码
-
将
.map更改为.map<Widget>。下次请用搜索,这个已经问了很多次了