flutterlocation icon indicating copy to clipboard operation
flutterlocation copied to clipboard

StreamSubscription prevents additional getLocation's on iOS.

Open FlashJonas opened this issue 7 years ago • 1 comments

Describe the bug I recently added

    locationStreamSub =
        location.onLocationChanged().listen((LocationData currentLocation) {
        print("new location: latitude ${currentLocation.latitude}");
    });

to my code and suddenly my manual button-triggered currentLocation = await location.getLocation(); stopped working on iOS, except the first time when it's called automatically, before stream is listened to. The getLocation call "fails silently" like denied requests do on iOS. I.e. "try-catch" does not catch this, and any code after await getLocation is never called.

If I never add my subscription, I can call getLocation perfectly as many times as I'd like.

Expected behavior I expect that after listening to location changes I should be able to manually trigger a getLocation() call as well. (Since I might have inadequate distance and time filters set on the stream subscription).

Tested on:

  • Android, API Level 28, simulator (works)
  • iOS, Version 12.4, simulator and real device 12.2 (only works if I don't subscribe to stream).

FlashJonas avatar Nov 07 '19 14:11 FlashJonas

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 07 '19 14:12 stale[bot]