frederickcxa / conditional-builder

Synchronous conditional widget renderer for Flutter :fire:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ConditionalBuilder

Synchronous conditional widget renderer.

Lets you declaratively render a widget based on a condition, using this you can get rid of implicit conditional statements in your code to display/hide a widget.

Usage

After following the installation guide, you can use this widget as follow:

ConditionalBuilder(
  condition: true,
  builder: (context) {
    return Text('This gets rendered');
  },
 )

ConditionalBuilder(
  condition: false,
  builder: (context) {
    return Text('This does not get rendered, an empty Container will be rendered');
  },
)

ConditionalBuilder(
  condition: false,
  builder: (context) {
    return Text('This does not get rendered, as fallback is not null, it is used to render the fallback widget.');
  },
  fallback: (context) {
    return Text('This gets rendered');
  }
)

About

Synchronous conditional widget renderer for Flutter :fire:

License:Other


Languages

Language:Dart 84.3%Language:Java 15.7%