How to find the size or position of any widget in flutter?

RenderBox renderbox =
widgetKey.currentContext!.findRenderObject() as RenderBox;
Offset position = renderbox.localToGlobal(Offset.zero);
double x = position.dx;
double y = position.dy;
debugPrint([x, y].toString());
final Size size = renderbox.size;
debugPrint(size.toString());

Here, widgetKey is the GlobalKey assigned to the widget of which size and position we have to find the size and position.

x and y denotes the coordinates of the top left point.

All other coordinates can be find out by using size. Size has height and width. e.g. x+size.width, y-size.height

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response