I would like to create several containers in a scaffold.
Do I have to create them manually or can I reduce the code by using an if with counter statement to generate them?
If I can use an if statement could you provide a simple example?
Thanks.
I would like to create several containers in a scaffold.
Do I have to create them manually or can I reduce the code by using an if with counter statement to generate them?
If I can use an if statement could you provide a simple example?
Thanks.
This is pretty vague. It really depends on what you need. But yes, you can use if() and even for() in the widget tree. Here is an example for each of them :
// State variable
var list = ["first", "second"];
// in build() method
if(list.isNotEmpty)
Container()
Column(children: [
for(var item in list)
Container(child: Text(item))
])