Get “y” position of container on Flutter

You can use GlobalKey for getting size or position of widget

GlobalKey key = GlobalKey(); // declare a global key

add key to your widget, whose position you need to find

Container(
   key: key,
   ...
); 

get the position using a renderbox

RenderBox box = key.currentContext.findRenderObject() as RenderBox;
Offset position = box.localToGlobal(Offset.zero); //this is global position
double y = position.dy; //this is y - I think it's what you want

Leave a Comment