Reputation: 827
I have some class like this
class View1 extends StatelessWidget {
@override
Widget build(BuildContext ctx) {
return Center(child: Text('Something'));
}
}
class View2 extends StatelessWidget {
....
}
How can I add them into a list and assigned to the children: <Widget>[]
.
For example, instead of
children: <Widget>[
view1()
//or view2
]
I want
children: <Widget>[
//for loop or something
list[i]
]
UPDATE:
The List a creat like this
List list=['view1()','view(2)']
and I got The argument type 'String' can't be assigned to the parameter type 'Widget'.
when I try
children: <Widget>[
Container(
child: list,
)]
Upvotes: 1
Views: 48