Search code snippets, questions, articles...

Create 10 container widgets using loop flutter

We can create a list of widgets using for loop in flutter. You can check the below example for that where we are creating 10 container widgets.
    children: [
        for (int i = 0; i < 9; i++) Container(child: Text(i))
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.
    children: [
        for (var item in [1,2,3]) Text(item)
In the above example, we have a list that contains three items in number format. We can loop through this list to generate multiple widgets as Row widget children.
Was this helpful?