measure_size 4.0.0 copy "measure_size: ^4.0.0" to clipboard
measure_size: ^4.0.0 copied to clipboard

A widget that provides a callback that is triggered when its size changes

measure_size #

A stateful widget that measures the size of a child widget immediately after it is rendered.

CAUTION: Does not work with PreferredSizeWidget

Measuring text and drawing an overlay with matching size
import 'package:measure_size/measure_size.dart';

MeasureSize(
    onChange: (Size newSize) {
        /// [newSize] will be the displayed size of [Widget child]
    },
    child: Text('Lorem ipsum dolor sit amet'),
);

MeasureSize #

Required

  • Widget child - This widget will be displayed and and measured.

Optional

  • void onChange(Size newSize) - A callback that is fired exactly once after the first frame of the child widget is rendered.

Example #

A quick demonstration can be found in the example directory. To run the example:

flutter run example/main.dart

Credits #

Thanks to Gene Bo and Dev Aggarwal for this code in a stackoverflow answer: https://stackoverflow.com/a/60868972

33
likes
160
points
26.7k
downloads

Publisher

verified publisherqrl.app

Weekly Downloads

A widget that provides a callback that is triggered when its size changes

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on measure_size