flutter_conditional_rendering
2.1.0, released 3 years ago by an unverified publisher
Provides conditional rendering widgets for if-else and switch cases
WASM-ready
What it does
The package offers `Conditional` and `ConditionalSwitch` widgets that let you render a single widget or a list of widgets based on a condition or a value. It supports null‑safe builder callbacks and optional fallback widgets.
AI-written summary of version 2.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need readable conditional rendering for complex widget trees
- You want to render a list of widgets conditionally
- You prefer a declarative API over inline ternary operators
Skip it when
- You only need a simple ternary expression
- You are already using a state‑management solution that handles conditional UI
Strengths
- Improves readability of complex conditional UI
- Supports both single widgets and lists
- Null‑safe and fully typed API
Weaknesses
- Only handles rendering, not state management
- No built‑in support for async or streams
- Limited to Flutter UI, no platform features
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Conditional.single(
context: context,
conditionBuilder: (ctx) => someCondition,
widgetBuilder: (ctx) => Text('True'),
fallbackBuilder: (ctx) => Text('False'),
),
],
);
}
}Alternatives
Packages that do the same job and could replace flutter_conditional_rendering.
- app_bar_with_search_switch
AppBar that toggles into a search field with optional animations
43Compare