Skip to content

Instantly share code, notes, and snippets.

@crizant
Created February 7, 2020 17:25
Show Gist options
  • Save crizant/2cda1212db6dd99984c57af13cfd118f to your computer and use it in GitHub Desktop.
Save crizant/2cda1212db6dd99984c57af13cfd118f to your computer and use it in GitHub Desktop.
Flutter conditional rendering plugin: switch condition list
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: ConditionalSwitch.list<String>(
context: context,
valueBuilder: (BuildContext context) => 'A',
caseBuilders: {
'A': (BuildContext context) => <Widget>[
Text('Widget A'),
Text('Widget B'),
],
'B': (BuildContext context) => <Widget>[
Text('Widget C'),
Text('Widget D'),
],
},
fallbackBuilder: (BuildContext context) => <Widget>[
Text('None of the cases matched!'),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment