get_widget_properties 0.0.1 copy "get_widget_properties: ^0.0.1" to clipboard
get_widget_properties: ^0.0.1 copied to clipboard

Package for obtaining the widget position and size in the app

get_widget_properties #

Package for obtaining the widget position and size in the app

Getting Started #

This package was created in order to obtained the position and the size of the widget in the app.

The position will begin in the app's top left corner, which may later be utilised in the Positioned widget as top left. You can't use any other GlobalKey inside the child of this Widget because the package relies on it. It will produce a duplicated key error.

A child and properties were required parameters for the widget. The properties function returns both the size and the location of the child widget. Please notice that the child widget will be wrapped in Wrap widget to retrieve the child widget's exact position without any expansion. As a result, it may interfere with certain of your parent widgets, such as the Column or Row widget.

example:

{@tool snippet Sample--template=stateful_widget_material}

  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisSize: MainAxisSize.max,
          children: [
            GetWidgetPosition(
              location: (properties) => print(
                  'This text location is at (${properties.position.dx},${properties.position.dy})\nThis widget has a width: ${properties.size.width}, height:${properties.size.height}'),
              child: Text(
                'Hello World',
                textAlign: TextAlign.center,
              ),
            ),
          ],
        ),
      ),
    );
  }

{@end-tool}

1
likes
90
pub points
0%
popularity

Publisher

unverified uploader

Package for obtaining the widget position and size in the app

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on get_widget_properties