What is the difference between globalposition and localposition in flutter?
1,496
GlobalPosition is the coordinate of a point on-screen with the top-left corner of the screen as the origin. Whereas LocalPosition is the coordinates of a point inside a RenderBox with the top-left corner of the RenderBox as the origin. If you are getting the same value, it means that your RenderBox top-left corner is the same as the screen top-left corner.
![Manoj Perumarath](https://i.stack.imgur.com/11xsg.jpg?s=256&g=1)
Author by
Manoj Perumarath
ചവറു പോലെ എഴുതുന്നത് എനിക്ക് ഇഷ്ടമല്ല ! Hey there, if you have found my answers helpful you can buy me a coffee! Currently, Senior Mobile Developer at Emvigo Technologies, Kaloor, Ernakulam, Kerala.
Updated on December 10, 2022Comments
-
Manoj Perumarath over 1 year
Somehow I'm getting same values for both, I'm not able to understand the difference between global and local position in flutter.
RenderBox getBox = context.findRenderObject(); Offset position = getBox.localToGlobal(Offset.zero); var local = getBox.globalToLocal(update.globalPosition);
-
MarcG about 5 yearsMore precisely, it just means that your RenderBox top-left corner is the same as the screen top-left corner.
-
Ryosuke about 5 years@MarcG yeah that sounds more accurate.
-
genericUser over 2 yearsremove that line "If you are getting the same value, then it just means that your RenderBox is covering the whole screen", it's wrong