https://github.com/frederickcxa/conditional-builder
Synchronous conditional widget renderer for Flutter :fire:
https://github.com/frederickcxa/conditional-builder
android dart declarative-ui flutter ios
Last synced: 5 months ago
JSON representation
Synchronous conditional widget renderer for Flutter :fire:
- Host: GitHub
- URL: https://github.com/frederickcxa/conditional-builder
- Owner: frederickcxa
- License: other
- Created: 2019-04-01T04:05:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-08-09T17:21:14.000Z (almost 5 years ago)
- Last Synced: 2025-10-23T02:53:04.354Z (8 months ago)
- Topics: android, dart, declarative-ui, flutter, ios
- Language: Dart
- Homepage:
- Size: 9.77 KB
- Stars: 14
- Watchers: 1
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```dart
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');
}
)
```