wongpiwat / trust-location

A Flutter plugin for detecting mock location on Android device. (Supports only high accuracy location mode)
https://pub.dev/packages/trust_location
BSD 3-Clause "New" or "Revised" License
15 stars 8 forks source link

Make it async, blank screen issue #21

Open singhtaranjeet opened 11 months ago

singhtaranjeet commented 11 months ago

https://github.com/wongpiwat/trust-location/blob/5cadf15887cfdc0f0c50f5cc19542b5db51b5239/android/src/main/java/com/wongpiwat/trust_location/LocationAssistant.java#L495

Your code is written in this manner... Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); onLocationChanged(location);

Due to this people are facing issues and they have created the issue in geolocator but actual issue is in this package

Geolocator issue: https://github.com/Baseflow/flutter-geolocator/issues/1296

As this package [trust-location] is used in safe_device so it is creating problem there, and due to this another is issue reported in safe_device

https://github.com/ufukhawk/safe_device/issues/33

By making it async

LocationServices.getFusedLocationProviderClient(context).getLastLocation().addOnSuccessListener(location -> { if (location != null) onLocationChanged(location); });

we don't get blank screen issue.