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

Share:
760
towhid
Author by

towhid

Love to design and develop tools that help others to solve their problems.

Updated on December 21, 2022

Comments

  • towhid
    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
      John Joe almost 4 years
      print out serviceStatus. Maybe if code not executed?
    • towhid
      towhid almost 4 years
      the code is executed, i know for sure because it shows the GPS dialog.
    • John Joe
      John Joe almost 4 years
      I not familar with that plugin. It seems like you need set permission?
    • towhid
      towhid almost 4 years
      yes, 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
      Sathish Gadde almost 4 years
      Just clean and build your project. May it is build issue. Same code working fine for me.