conditional_parent_widget 0.0.1
conditional_parent_widget: ^0.0.1 copied to clipboard

Conditionally wrap a child widget with a parent widget.

conditional_parent_widget #

Conditionally wrap a subtree with a parent widget without breaking the code tree.

  • condition: the condition depending on which the subtree child is wrapped with the parent.
  • child: The subtree that should always be build.
  • parentBuilder: builds the parent with the subtree child iff condition is true.

Usage:

 return ConditionalParentWidget(
   condition: shouldIncludeParent,
   child: Widget1(
     child: Widget2(
       child: Widget3(),
     ),
   ),
   parentBuilder: (Widget child) => SomeParentWidget(child: child),
);

Instead of:

 Widget child = Widget1(
   child: Widget2(
     child: Widget3(),
   ),
 );
///
 return shouldIncludeParent ? SomeParentWidget(child: child) : child;
1
likes
120
pub points
0%
popularity

Publisher

Unknown

Conditionally wrap a child widget with a parent widget.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on conditional_parent_widget