-
-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: App delay and crash on second launch using geolocator package #1603
Comments
Dear @jaimisdomadiya, It is possible that it takes some time to retrieve your location. Do you have a crashlog that we can take a look at? Kind regards, |
Hi team, Thank you for your response. Here’s a detailed update regarding the issue: Current Issue and Behavior First Launch: On the first launch, the app behaves as expected:
Second Launch (App Relaunch After Forced Kill): After closing (killing) the app and reopening it, the following behavior is observed:
Terminal Logs
|
The same thing happens to me, it works fine the first time, then you close the app and go back in and that's when it takes about 20 seconds or the app breaks. The problem always occurs after accepting the location permissions and it only happens on Android geolocator: ^13.0.2 @override
Widget build(BuildContext context) {
final appRouter = ref.watch(appRouteProvider);
ref.watch(requestPermissionsProvider);
return MaterialApp.router(
key: navigatorKey,
supportedLocales: const [Locale('es'), Locale('en')],
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
debugShowCheckedModeBanner: false,
routerConfig: appRouter,
);
} /////// @Riverpod(keepAlive: true)
Future<void> requestPermissions(ref) async {
if (await Permission.location.request().isGranted) {
print('Permiso otorgado');
} else {
print('Permiso denegado');
}
} |
+1 |
1 similar comment
+1 |
Please check the following before submitting a new issue.
Please select affected platform(s)
Steps to reproduce
Add the geolocator package to your Flutter project (version 13.0.1).
Implement location permission requests and retrieval in your main app file, as shown in the code sample.
Run the app on an Android device (Android 14 or others).
On the first launch, the location request works as expected.
Close the app completely (kill the process) and relaunch it.
Observe that on the second launch, the app either takes a long time to load or crashes.
Expected results
The app should retrieve the location data and proceed to the home screen within a reasonable time on all launches, including subsequent launches after being killed.
Actual results
On the second launch (after killing the app):
The app often takes a long time to retrieve location data and load the home screen, or
The app sometimes crashes, failing to load at all.
Code sample
Code sample
Code sample
Screenshots or video
Screenshots or video demonstration
[Upload media here]
Version
Geolocator Package Version: 13.0.1 play-services-location Version: 21.1.0
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: