getLocation static method
dynamic
getLocation()
Implementation
static getLocation() async {
Log.i(tag,'getLocation');
bool serviceEnabled;
LocationPermission permission;
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
Log.i(tag,'getLocation:Location services are disabled.');
Geolocator.openLocationSettings();
return;
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
Log.i(tag,'getLocation:Location permissions are denied');
return;
}
}
if (permission == LocationPermission.deniedForever) {
Log.i(tag,'getLocation:Location permissions are permanently denied, we cannot request permissions.');
return;
}
Position position= await Geolocator.getCurrentPosition();
PocHandler.receiveLocation(position.latitude, position.longitude, position.speed, position.heading, position.altitude);
}