getPosition() is an asynchronous method that returns a Future. It leverages a Geolocator class to retrieve the last known position of the user.
Now the question may arise: where should getPosition be called? As the position should be retrieved only once, the obvious choice should be leveraging the initState method, which only gets called once, when the widget is loaded.
It is recommended to keep initState synchronous, therefore you can use the then syntax to wait for the callback and update the state of the widget. myPosition is a state String variable that contains the message the user will see after the device has retrieved the coordinates, and it includes the latitude and longitude.
In the build method, there is just a centered Text containing the value of myPosition, which is empty at the beginning and then shows the string with the coordinates.