Bug on Samsung Note 10
i use this command to get location
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
But with Samsung Note 10, it does not work. And not run next command and not throw any exception.
Hey @kekedaine, could you please give us some more information about this bug?
I have the same issue on Galaxy note 8.
Future getFirstLocation() async {
Position position;
print("getfirstlocation");
GeolocationStatus geolocationStatus = await Geolocator().checkGeolocationPermissionStatus();
print("geolocationStatus: ${geolocationStatus}");
var temp = Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.lowest).catchError((e)=> {print("then")});
print("temp= $temp");
try {
position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
} catch (error) {
print("getfirstlocation error 1");
try {
position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
} catch (error) {
print("error in geolocation $error");
}
}
print("getfirstlocation position: $position");
prints
getfirstlocation geolocationStatus: GeolocationStatus.granted temp= Instance of 'Future
'
No errors are thrown nor catched. The Future seems to never resolve nor fail. No code further down in the function is called (which of course breaks my app).
*Edit: This is the only Android phone I have to test on, so can't tell if this works on other phones. But it still works on iOS.
Switching out geolocator: ^5.1.3 for the alternative library: location: ^2.3.5 (and updating the code of course) works on Galaxy Note8 as a desperate fix while this is being solved.
@FlashJonas Did you try to run the app on an emulator? You could do this to test if the bug depends on the device or the code itself.
Edit: I reproduced your code on an emulator and got the following output: LAT: 37.4219983, LNG: -122.084
Same here on Note 4: the example always return nulls only on that device, it works on my others Android devices
@StijnWoerkom This bug still appears in the latest plugin.
I have the same issue on Android emulator ... I try to print the position when a screen is initialized. There is my code :
class _LoadingScreenState extends State<LoadingScreen> {
void printPosition() async {
GeolocationStatus geolocationStatus =
await Geolocator().checkGeolocationPermissionStatus();
print(geolocationStatus);
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
print(position);
}
@override
void initState() {
print('init');
super.initState();
printPosition();
}
@override
Widget build(BuildContext context) {
return Scaffold();
}
}
And the console result :
I/flutter ( 6254): init I/flutter ( 6254): GeolocationStatus.granted
This bug is solved with version 6.0.0 of the geolocator plugin.