Skip to content
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

attempting to use await for causes issues. #12

Closed
tensor-programming opened this issue Apr 22, 2018 · 0 comments
Closed

attempting to use await for causes issues. #12

tensor-programming opened this issue Apr 22, 2018 · 0 comments

Comments

@tensor-programming
Copy link

I am building an application for a tutorial that I am writing and I am finding that when I use any of the methods aside from lastKnownLocation(), I can't get access to the one shot data in the streams using the await for construct.

From what I can tell based on the documentation, the currentLocation() method should just be a stream with a single value inside of it and yet when I write something like the block below, the application just sits indefinitely waiting for the stream to complete (I tried adding an onDone and onError to see if there were any problems in that regard).

getLocation() async {
  LocationResult location;
    Stream<LocationResult> results = Geolocation.currentLocation(
        accuracy: LocationAccuracy.best, inBackground: false);

    await for (LocationResult data in results) {
      location = data;
    }

    return location;
}

I did a bit of debugging and it seems that the data and location variables stay null the entire time the function is running. Am I just missing something here?

Also, I have a question regarding the lastKnownLocation() function. Based on the android documentation, it should change with some degree of frequency and yet, even if I turn off the GPS and rebuild the application, the last known location will not change unless I power down the emulator and reboot it. Is this just how it works or is it something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant