Skip to content
pubscout

measure_size

5.0.2, released 11 months ago by qrl.app

Widget that reports its size changes via a callback.

WASM-ready
$ flutter pub add measure_size
Source repository

What it does

Provides a MeasureSize widget that calls a callback with the rendered size of its child. MeasureSizeBuilder can measure multiple prototypes in a single layout pass.

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

Use it when

  • You need to react to a widget's size after it is rendered
  • Building adaptive layouts that depend on actual widget dimensions

Skip it when

  • You require size information before the first layout pass
  • You need to measure PreferredSizeWidget reliably

Strengths

  • Low overhead size detection
  • Simple API with just a child and onChange callback
  • MeasureSizeBuilder can handle multiple widgets efficiently

Weaknesses

  • Does not work with PreferredSizeWidget on the first frame
  • Only provides size after layout, not during build

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:measure_size/measure_size.dart';

Widget child = Text('Lorem ipsum');

MeasureSize(
  onChange: (Size newSize) {
    // newSize is the displayed size of child
  },
  child: child,
);

Alternatives

Packages that do the same job and could replace measure_size.

Works with

Packages commonly used together with measure_size: ones it builds on, ones built on it, and its own family.