lundi 3 août 2020

How to add elements to a column if there is a condition in flutter?

I have this code:

Column(
        children: [
            MyFirstWidget(),
            MySecondWidget(),
        ],
);

Now I want to add some widgets to that column if there is a condition. Here an example:

Column(
        children: [
            MyFirstWidget(),
            MySecondWidget(),
            if(condition == true) {
               MyThirdWidget(),
               MyFourthWidget(),
            }
        ],
);

I know this code is wrong, but how can I do this is correct dart programming?

Aucun commentaire:

Enregistrer un commentaire