intrinsic_size_builder
2.0.2, released 3 years ago by martinsellergren.dev
Finds the intrinsic size of a widget and provides it in a convenient builder.
WASM-ready
What it does
Finds the intrinsic size of a widget prior to adding it fully to the widget tree and provides it in a builder function. It renders the subject with zero opacity for one frame to calculate dimensions, then displays the real widget.
AI-written summary of version 2.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to know a widget's intrinsic size before or during layout construction
- Building a SliverAppBar with a dynamically sized flexible space or bottom
Skip it when
- You cannot tolerate a single-frame transparent measurement phase without a fallback loading state
- Standard layout primitives like IntrinsicWidth or IntrinsicHeight already solve your layout constraints
Strengths
- Convenient builder pattern for intrinsic size measurement
- Supports refreshing sizes when subject dimensions change
- Allows specifying a first-frame widget to avoid visual glitches
Weaknesses
- Requires a 1-frame layout pass with zero opacity which can cause a visual glitch if not handled
- Requires manual refresh calls when the subject changes size
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
IntrinsicSizeBuilder(
subject: const Text(
'Hello world',
style: TextStyle(fontSize: 25),
),
builder: (context, subjectSize, subject) => Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
subject,
Text('The size of subject is $subjectSize'),
],
),
),
)