Skip to content

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

License

Notifications You must be signed in to change notification settings

PhillDubois/measure_size

 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 56.4%
  • HTML 20.3%
  • Swift 20.2%
  • Kotlin 2.4%
  • Objective-C 0.7%