Reputation: 1344
I am getting the above error (question) with the following code:
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(),
dummy_data
const DUMMY_CATEGORIES = const [
Category(
id: 'c1',
title: 'Italian',
color: Colors.purple,
),
Category(
id: 'c2',
title: 'Quick & Easy',
color: Colors.red,
),
];
I am just following a tutorial. The instructor did not get the error. :(
Upvotes: 0
Views: 2776
Reputation: 891
specify the type of the map map<Widget>
DUMMY_CATEGORIES
.map<Widget>((categoryData) => CategoryItem(
categoryData.title,
categoryData.color,
))
.toList(),
Upvotes: 1