Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between globalposition and localposition in flutter?

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);
like image 824
Manoj Perumarath Avatar asked Apr 21 '19 13:04

Manoj Perumarath


Video Answer


1 Answers

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.

like image 134
Ryosuke Avatar answered Nov 15 '22 11:11

Ryosuke