Closed codersangam closed 2 years ago
have you found the solution yet?
Use Null Safety:static List<Item>? items;
Thankyou!!1 i have another problem though in catalog.dart ---code---
factory Item.fromMap(Map<String, dynamic> map) { if (map == null) return null;
return Item(
id: map['id'],
name: map['name'],
desc: map['desc'],
price: map['price'],
color: map['color'],
image: map['image'],
);
}
--------A value of type 'Null' can't be returned from the constructor 'Item.fromMap' because it has a return type of 'Item'.
checkout here: https://github.com/codersangam/thirtydays_flutter
Thankyou !!
I removed the first item which is added on catalog.dart . Logically if we see, it can be null so that we fetch data from network or json files. But after removing that first item. It shows an error.
class CatalogModel { static List<Item> items; }
Please review it once.