Skip to content

Instantly share code, notes, and snippets.

@crizant
Created February 7, 2020 17:21
Show Gist options
  • Save crizant/f92222e37da0213805911a9bab392185 to your computer and use it in GitHub Desktop.
Save crizant/f92222e37da0213805911a9bab392185 to your computer and use it in GitHub Desktop.
Flutter conditional rendering plugin: if-else condition
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
context: context,
children: <Widget>[
Conditional.single(
conditionBuilder: (BuildContext context) => someCondition == true,
widgetBuilder: (BuildContext context) => Text('The condition is true!'),
fallbackBuilder: (BuildContext context) => Text('The condition is false!'),
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment