Flutter Conditional Wrap

Pub

A widget that allows you to conditionally wrap a child subtree with a parent widget

Usage

Simply wrap the widget subtree with a ConditionalWrap widget and pass the required properties.

ConditionalWrap(
  condition: shouldIncludeParent,
  positiveBuilder: (context, child) => ParentWidget(child: child),
  child: ChildSubtree(),
),

You can also provide an alternative builder to use when the condition is false.

ConditionalWrap(
  condition: shouldUsePositiveBuilder,
  positiveBuilder: (context, child) => ParentWidget(child: child),
  negativeBuilder: (context, child) => AlternativeParent(child: child),
  child: ChildSubtree(),
),

Libraries

conditional_wrap