getGeoLocation static method
Gets location string "lat,long"
Implementation
static Future<String> getGeoLocation() async {
try {
bool enabled = await Geolocator.isLocationServiceEnabled();
if (!enabled) return "0,0";
LocationPermission perm = await Geolocator.checkPermission();
if (perm == LocationPermission.denied) {
perm = await Geolocator.requestPermission();
if (perm == LocationPermission.denied ||
perm == LocationPermission.deniedForever) {
return "0,0";
}
}
final pos = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.best);
return "${pos.latitude},${pos.longitude}";
} catch (e) {
return "0,0";
}
}