Skip to content
pubscout

prototype_constrained_box

2.0.6, released 8 weeks ago by mateusfccp.me

A ConstrainedBox widget where constraints are determined by another prototype widget.

WASM-ready
$ flutter pub add prototype_constrained_box
Source repository

What it does

PrototypeConstrainedBox behaves like a standard ConstrainedBox, but instead of taking explicit BoxConstraints, it takes another widget to act as the prototype for sizing constraints. You can constrain the child loosely or tightly in one or both axes based on the prototype.

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

Use it when

  • You need a widget to match the size or constraints of another prototype widget.
  • You want to constrain a child widget tightly or loosely based on dynamic content sizing.

Skip it when

  • You already have explicit BoxConstraints and can simply use a standard ConstrainedBox.

Strengths

  • Simplifies sizing elements based on a prototype widget.
  • Provides convenient constructors like tight, loose, and tightFor.

Weaknesses

  • Adds widget tree complexity compared to native sizing or basic constraints.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
const PrototypeConstrainedBox.tight(
  prototype: Text('Lorem ipsum dolor'),
  child: ColoredBox(
    color: Color(0xFFFF0000),
  ),
);

Alternatives

Packages that do the same job and could replace prototype_constrained_box.