I am new to Dart and I am currently stuck on how to add multiple children in a body. Right now I need to add 4 children in a body and I do not know what to do.
I have tried this:
This is my body:
body: Column(
children: [
LinkBox(), // Add the link box here
Expanded(child: MyHomePage()),
],
),
I need to add the following children into my body:
I have tried to do this:
body: Column(
children: [
LinkBox(), // Add the link box here
Expanded(child: MyHomePage()),
Expanded(child: ShoppingItem()),
Expanded(child: ShoppingGallery()),
],
),
Also tried to do this:
body: Column(
children: <Widget>[
LinkBox(), // Add the link box here
MyHomePage(),
ShoppingItem(),
ShoppingGallery(),
],
),
And also this:
body: Column(
children: <Widget>[
LinkBox(), // Add the link box here
Expanded(child: MyHomePage()),
Expanded(child: ShoppingItem()),
Expanded(child: ShoppingGallery()),
],
),
It resulted with a lot of problems and I could not run the code on DartPad.
I want it to look like this:
with this below:
These are the problems that dart pad resulted in:
As in error message, your widgets ShoppingItem
and ShoppingGallery
have required parameters which you did not provide, those are name
, priceRange
and rating
. You are unable to build Flutter/Dart app without required parameters. Please read https://dart.dev/language/classes to know more about how classes work in dart (Widgets are essentially dart classes)