proviso 1.0.5 copy "proviso: ^1.0.5" to clipboard
proviso: ^1.0.5 copied to clipboard

Complete set of tools for widgets conditional rendering and wrapping. Conditional widgets and builders.

example/example.md

The simplest usage (ConditionWidget and ConditionBuilder)

Row(
  children: [
    ConditionWidget(
      condition: starred,
      widget: Icon(
        Icons.favorite
      )
    ),
    ConditionWidget(
      condition: archived,
      widget: Icon(
        Icons.archive
      )
    )  
  ]
)
ConditionBuilder(
  condition: (_) => someCondition,
  trueBuilder: (_) => trueWidget,
  fallbackBuilder: (_) => fallbackWidget
);

ConditionalBuilder for single widget

ConditionalBuilder.widget(
  context: context,
  condition: (_) => _evaluateSomething(),
  trueBuilder: (_) => trueWidget,
  fallbackBuilder: (_) => fallbackWidget,
);

ConditionalBuilder for widget list

ConditionalBuilder.widgets(
  context: context,
  condition: (_) => true,
  trueBuilder: (_) => trueWidgetList,
  fallbackBuilder: (_) => fallbackWidgetList,
)

SwitchCaseBuilder for single widget

final Widget targetConditionWidget = Container();
final Widget fallbackWidget = Container();

SwitchCaseBuilder.widget<String>(
  context: context,
  condition: (_) => '1',
  caseBuilders: {'1': (_) => targetConditionWidget, '2': (_) => Container()},
  fallbackBuilder: (_) => fallbackWidget,
);  

SwitchCaseBuilder for widget list

final List<Widget> targetConditionWidgetList = [Container()];
final List<Widget> fallbackWidgetList = [Container()];

SwitchCaseBuilder.widgets<String>(
context: context,
condition: (_) => '1',
caseBuilders: {'1': (_) => targetConditionWidgetList},
fallbackBuilder: (_) => fallbackWidgetList,
)  

Conditional parent widget

ConditionalWrap(
  shouldWrap: shouldWrapChildInParent,
  child: Container(),
  parentBuilder: (child) => Container(
    child: child,
  ),
)

try/catch builders

SafeBuilder(
  widgetBuilder: (_) => validWidget,
  fallbackBuilder: (e, _) => fallbackWidget, // called if widgetBuilder fails with error
)
5
likes
160
points
94
downloads

Publisher

verified publishermos-dev.com

Weekly Downloads

Complete set of tools for widgets conditional rendering and wrapping. Conditional widgets and builders.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on proviso