Flutter Location package requestService() never returns
760
I had the same issue. It could be solved by upgrading your Flutter project, follow this link https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
Author by
towhid
Love to design and develop tools that help others to solve their problems.
Updated on December 21, 2022Comments
-
towhid over 1 year
I have a function like this. Using Location package from flutter it shows the dialog to enable GPS.
Future<bool> _checkServiceStatus() async { final Location location = Location(); bool serviceStatus = await location.serviceEnabled(); if (!serviceStatus) { serviceStatus = await location.requestService(); print('status -> $serviceStatus'); } return serviceStatus; }
When its calling await location.requestService(), it is showing the dialog to enable GPS but after that it never returns the result. Even its not executing the print() function.
What am i doing wrong here?
Any help would be very appreciated! Thanks in advance.
-
John Joe almost 4 yearsprint out
serviceStatus
. Maybeif
code not executed? -
towhid almost 4 yearsthe code is executed, i know for sure because it shows the GPS dialog.
-
John Joe almost 4 yearsI not familar with that plugin. It seems like you need set permission?
-
towhid almost 4 yearsyes, it shows the dialog to enable my GPS i.stack.imgur.com/u9Q4D.png after that it just stops, the future never returns and next line never executes (print function)
-
Sathish Gadde almost 4 yearsJust clean and build your project. May it is build issue. Same code working fine for me.
-