Column(
children: [
Widget1(),
Widget2(),
Expanded(
child: SingleChildScrollView(
child: Container(
child: Column(
children: [
for(var i =0 ;i<categories.length;i++){
DetailsCard(catName: categories[i]);
}
],
),
),
),
),
],
)
In the above code i want to add multiple widgets based on the items in the categories list . But when I try using the for loop i keep getting "The element type ‘Set’ can’t be assigned to the list type ‘Widget’." error.
>Solution :
use for statement inside of [...] like below:
Column(
children: [
Widget1(),
Widget2(),
Expanded(
child: SingleChildScrollView(
child: Container(
child: Column(
children: [
for(var i =0 ;i<categories.length;i++)
DetailsCard(catName: categories[i])
],
),
),
),
),
],
)
do not add {} and ; in [...] statement, it is illegal