I would like to put a switch statement inside of my Column to decide what mix of children widgets to buildin my FLUTTER APP.
In my specific case I have created an enum with 4 different possible states (AnimationEnum.None, AnimationEnum.etc), each triggering a different build mix of children.
I can get this working fine by writing an if statement above EVERY possible widget, but that is clearly an inefficient way of doing things, and want to streamline my code.
I feel like I am close but cant quite get there. Here is a simplified version of the code with placeholder widgets:
thanks!
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
switch(widget._cardAnimType)
case AnimationEnum.None: {
Widget1('args'),
Widget2('args'),
Widget3('args'),
//etc
break;
}
case AnimationEnum._card1Correct: {
Widget1('args'),
Widget2('args'),
Widget3('args'),
//etc
break;
}
///more switch statements here...
]
),
),
),