Skip to content

Instantly share code, notes, and snippets.

@sbis04
Created May 30, 2020 09:45
Show Gist options
  • Save sbis04/ee582351a51df5451c277bbb9ce44c68 to your computer and use it in GitHub Desktop.
Save sbis04/ee582351a51df5451c277bbb9ce44c68 to your computer and use it in GitHub Desktop.
// Method for retrieving the current location
_getCurrentLocation() async {
await _geolocator
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high)
.then((Position position) async {
setState(() {
// Store the position in the variable
_currentPosition = position;
print('CURRENT POS: $_currentPosition');
// For moving the camera to current location
mapController.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(
target: LatLng(position.latitude, position.longitude),
zoom: 18.0,
),
),
);
});
}).catchError((e) {
print(e);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment