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

outdated

A Flutter package for widgets conditional rendering and wrapping.

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
0
pub points
51%
popularity

Publisher

verified publishermos-dev.com

A Flutter package for widgets conditional rendering and wrapping.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on proviso