I am developing a Flutter app, and my initial screen is a custom splash screen. I’m trying to get the user’s location on this screen. If the app gets the user’s location, it will open the home screen widget with the location data as an argument. This argument is nullable, so if I can’t get the location, the home screen will still work fine.
Here is my code to get the location:
if (permissionGranted) {
try {
final location = await Geolocator.getCurrentPosition();
try {
// do some API call
} catch (e) {
print(e);
}
if (!mounted) return;
router. go(
'/',
extra: LatLng(location.latitude, location.longitude),
);
} catch (e) {
print('Error obtaining location: $e');
router.go(
'/',
);
}
} else {
router.go(
'/',
);
}
I am using go_router for routing and calling this from my splash screen’s init method, which is an async function.
The code works fine on Android and also on a real iPhone SE device. However, when I try to run my app on an iPad Air (simulator) or iPhone 13 mini (simulator) with iOS 17.5.1, it gets stuck on the splash screen forever.
Due to this issue, my app has been rejected twice from the App Store.
Questions:
- Are there any known issues with the Geolocator package on iOS simulators for iOS 17.5.1?
- Could this be an issue with my implementation of the go_router?
- Are there any additional configurations required specifically for iOS simulators that I might be missing?
Any help to debug and solve this issue would be greatly appreciated.