proviso

Last updated:

0 purchases

proviso Image
proviso Images
Add to Cart

Description:

proviso

proviso #


A complete set of tools for conditional rendering (if-else and switch conditions),
subtree wrapping with a parent widget,
and some handy shortcuts (like DebugWidget, WebOnlyWidget, SafeBuilder, and many more). 👍
Install #
In flutter project add the dependency:
dependencies:
...
proviso: ^1.0.5
copied to clipboard
Why #
To make a more readable and simpler conditional statement code.
All variants of conditional rendering you will ever need in a single package #
in the form of widgets:
Row(
children: [
ConditionWidget(
condition: starred,
widget: Icon(
Icons.favorite
),
fallback: fallbackWidget
),
ConditionWidget(
condition: archived,
widget: Icon(
Icons.archive
)
)
]
)
copied to clipboard
ConditionBuilder(
condition: (_) => someCondition,
trueBuilder: (_) => trueWidget,
fallbackBuilder: (_) => fallbackWidget
);
copied to clipboard
builders:
ConditionalBuilder.widget(
context: context,
condition: (_) => _evaluateSomething(),
trueBuilder: (_) => trueWidget,
fallbackBuilder: (_) => fallbackWidget,
);
copied to clipboard
Switch case widgets and builders:
final Widget targetConditionWidget = Container();
final Widget fallbackWidget = Container();

SwitchCaseBuilder.widget<String>(
context: context,
condition: (_) => '1',
caseBuilders: {'1': (_) => targetConditionWidget, '2': (_) => Container()},
fallbackBuilder: (_) => fallbackWidget,
);
copied to clipboard
Conditional parent widget
ConditionalWrap(
shouldWrap: shouldWrapChildInParent,
child: Container(),
parentBuilder: (child) => Container(
child: child,
),
)
copied to clipboard
try/catch builders
SafeBuilder(
widgetBuilder: (_) => validWidget,
fallbackBuilder: (e, _) => fallbackWidget, // called if widgetBuilder fails with error
)
copied to clipboard
Conditionally render a single widget or a list of widgets
ConditionalBuilder.widgets(
context: context,
condition: (_) => true,
trueBuilder: (_) => [Container(), Container()],
fallbackBuilder: (_) => [],
)
copied to clipboard
Some more helpers like:
DebugOnlyWidget, WebOnlyWidget etc
copied to clipboard
Contributions #
Feel free to report bugs, request new features
or to contribute to this project!

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.