Skip to content
pubscout

conditional_wrap

3.0.0, released 4 years ago by an unverified publisher

A Flutter widget that conditionally wraps a child subtree with a parent widget.

WASM-ready
$ flutter pub add conditional_wrap
Source repository

What it does

Provides a WidgetWrapper component that evaluates conditions inside a wrapper function to decide whether to wrap a child widget or return it unwrapped. It simplifies conditional UI structures without verbose if-else statements.

AI-written summary of version 3.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to apply a parent widget conditionally based on a boolean flag.
  • You want to apply a wrapper only when a nullable value is present.

Skip it when

  • You are managing complex app state or navigation.
  • You prefer standard if-else widget creation directly in the build method.

Strengths

  • Simplifies conditional UI wrapping logic
  • Lightweight with no external dependencies other than Flutter

Weaknesses

  • Does very little that cannot be achieved with standard Dart if-else expressions
  • API has breaking changes across major versions

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
WidgetWrapper(
  wrapper: (child) => _condition
      ? ParentWidget(child: child)
      : child,
  child: ChildSubtree(),
)

Alternatives

Packages that do the same job and could replace conditional_wrap.