Flutterlocation: getLocation never returns

Created on 28 Mar 2020  路  3Comments  路  Source: Lyokone/flutterlocation

Describe the bug
I did a simple call to getLocation(), but it doesn't return anymore

Expected behavior
getLocation() returns an error or coordinates

Tested on:

  • Android, API Level 21, simulator

Additional logs

When I made the call, I see the following:
W/GCoreFlp( 2013): No location to return for getLastLocation() W/GCoreFlp( 2013): No location to return for getLastLocation() W/GCoreFlp( 2013): No location to return for getLastLocation() D/WifiService( 1539): acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@12bce7c6} D/WifiService( 1539): releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@12bce7c6} D/WifiService( 1539): acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@12bce7c6} D/WifiService( 1539): releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@12bce7c6} D/WifiService( 1539): acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@12bce7c6} D/WifiService( 1539): releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@12bce7c6}

Most helpful comment

Hi,

we had the exact same issue while trying to get users location multiple times.

Our solution was to make a variable named lastLocation, where we would write users location every time that getLocation() has succeeded and set a timeout on getter with:

LocationData lastLocation; - as a global variable

Location().getLocation().timeout(Duration(seconds: 1), onTimeout: () => lastLocation);

I hope it helps.

All 3 comments

Hello,
I want to add 2 more informations:

  1. I am testing the version 3.0.1
  2. A problem happen also with your "Flutter plugin demo", launched on an Android simulator with API Level 21. Every buttons that I press, get me an exception:

E/flutter ( 3640): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method hasPermission on channel lyokone/location)

E/flutter ( 3640): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getLocation on channel lyokone/location)

This is a big problem. Can you please verify yourself?

Thank you in advance

Hi,

we had the exact same issue while trying to get users location multiple times.

Our solution was to make a variable named lastLocation, where we would write users location every time that getLocation() has succeeded and set a timeout on getter with:

LocationData lastLocation; - as a global variable

Location().getLocation().timeout(Duration(seconds: 1), onTimeout: () => lastLocation);

I hope it helps.

Hello @Kristijan505,
thank you. I've implemented what you suggested to me.

Anyway I also want to add that the problem was due to the simulator with API 21. This one, is the only one that require the position to be setted from the simulator settings, and need also that the position don't need to be the standard one. If you don't change the default simulator position, the GPS is treated as deactivated even if you activated it from the phone settings (strange behavior).

Was this page helpful?
0 / 5 - 0 ratings