I'm trying to call the name and the price and image url from Items_list.dart,
here is the code for calling them: `
// this is to get items list info from the Items_lists.dart
final items item;
_FruitsState({@required this.item});
Error that I got:
The following NoSuchMethodError was thrown building:
The getter 'name' was called on null.
Receiver: null
Tried calling: name // and for the price and picture to not only name.
I'm trying to call the name and the price and image url from Items_list.dart,
here is the code for calling them: ` // this is to get items list info from the Items_lists.dart final items item; _FruitsState({@required this.item});
@override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(bottom: 0.0), child: GridView.builder( shrinkWrap: true, itemCount: fruitsItemsList.fruitsItems.length, gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: height / width / 3, ), itemBuilder: (BuildContext context, int index) { return single_fruit( prodName: item.name, prodPrice: item.price, prodPicture: item.picture, ); }), );`
//And this is the Items_list.dart: FruitsItemsList fruitsItemsList = FruitsItemsList(fruitsItems: [ items( id: 001, name: "kiwi", picture: "assets/kiwi1.jpg", price: 7, ), items( id: 002, name: "avocado", picture: "assets/a1.jpg", price: 11, ),
]);
class FruitsItemsList { List fruitsItems;
FruitsItemsList({@required this.fruitsItems});
}
class items { int id; String name; double price; String picture; int quantity;
items({ @required this.id, @required this.name, @required this.price, @required this.picture, this.quantity = 1, });
}
Error that I got: The following NoSuchMethodError was thrown building: The getter 'name' was called on null. Receiver: null Tried calling: name // and for the price and picture to not only name.