ConditionalModifier extension

Conditional and compositional modifiers for any widget.

Provides chainable methods for conditional widget wrapping, enabling clean, readable conditional UI logic without breaking the modifier chain.

on

Methods

applyIf(bool condition, Widget modifier(Widget widget)) → Widget

Available on Widget, provided by the ConditionalModifier extension

Applies a modifier only when condition is true.
applyUnless(bool condition, Widget modifier(Widget widget)) → Widget

Available on Widget, provided by the ConditionalModifier extension

Applies a modifier only when condition is false.
let(Widget transform(Widget widget)) → Widget

Available on Widget, provided by the ConditionalModifier extension

Transforms the widget through a function.
when(bool condition, {required Widget ifTrue(Widget widget), required Widget ifFalse(Widget widget)}) → Widget

Available on Widget, provided by the ConditionalModifier extension

Applies one of two modifiers based on a condition.
withBuilder(Widget builder(BuildContext context, Widget child)) → Widget

Available on Widget, provided by the ConditionalModifier extension

Wraps the widget with a builder function that has access to BuildContext.