conditional_wrap 0.0.1
conditional_wrap: ^0.0.1 copied to clipboard
A Flutter widget that allows you to conditionally wrap a child subtree with a parent widget
Flutter Conditional Wrap #
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(),
),