Skip to content

Instantly share code, notes, and snippets.

@sbis04

sbis04/main.dart Secret

Created May 30, 2020 09:16
Show Gist options
  • Save sbis04/87b855a5d459dd69ee2c67faea8fa8f0 to your computer and use it in GitHub Desktop.
Save sbis04/87b855a5d459dd69ee2c67faea8fa8f0 to your computer and use it in GitHub Desktop.
// Method for retrieving the address
_getAddress() async {
try {
// Places are retrieved using the coordinates
List<Placemark> p = await _geolocator.placemarkFromCoordinates(
_currentPosition.latitude, _currentPosition.longitude);
// Taking the most probable result
Placemark place = p[0];
setState(() {
// Structuring the address
_currentAddress =
"${place.name}, ${place.locality}, ${place.postalCode}, ${place.country}";
// Update the text of the TextField
startAddressController.text = _currentAddress;
// Setting the user's present location as the starting address
_startAddress = _currentAddress;
});
} catch (e) {
print(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment