Baseflow / flutter-geolocator

Android and iOS Geolocation plugin for Flutter
https://baseflow.com/
MIT License
1.24k stars 657 forks source link

How to detect Mock location using isMocked property #675

Closed FaizanMubasher closed 3 years ago

FaizanMubasher commented 3 years ago

This is what I am trying to do:

Future<Position> _determinePosition() async {
bool serviceEnabled;
LocationPermission permission;

serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
  return Future.error('Location services are disabled.');
}

permission = await Geolocator.checkPermission();
if (permission == LocationPermission.deniedForever) {
  return Future.error(
      'Location permissions are permanently denied, we cannot request permissions.');
}

if (permission == LocationPermission.denied) {
  permission = await Geolocator.requestPermission();
  if (permission != LocationPermission.whileInUse &&
      permission != LocationPermission.always) {
    return Future.error(
        'Location permissions are denied (actual value: $permission).');
  }
}
return await Geolocator.getCurrentPosition(
    desiredAccuracy: LocationAccuracy.high);
}

And call it like:

_determinePosition().then((position) { if (position.isMocked) { //.. Show error message return; }

But this if is never executed. Please guide how to detect Mock location correctly. I have FAKE GPS App and Mock Location turned on as well.

SO Post

SivaFullStackDeveloper commented 2 years ago

i am trying to make a fake Gps app but i am not getting how can i change location to google maps location and how can i get moack permission to my app? is it possible to do Fake gps app with flutter if not i will leave flutter and go to native development? please help me