-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P4area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-warningIssues with the analyzer's Warning codesIssues with the analyzer's Warning codestype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
I am using a stream to read out location data in a bloc. I have a start and a stop event. In the stop method, I cancel the stream subscription. When I use listen
to a stream to yield
the state the inside where the yield
statement is never gets called.
What really bugs me that I don't get any error message warning or compiler error
_locationSubscription = location.onLocationChanged.listen(
(location) async* {
if (location.isNotNull) {
yield LocationState.sendData(location: updateLocation(location));
}
},
);
When I replace the listen
to await for
I don't see any way
to stop this from yielding events because the subscription handle is gone.
Any ideas? Any explanations?
Stream<LocationState> _start() async* {
await Location()
.changeSettings(accuracy: LocationAccuracy.high, interval: 1);
await for (LocationData location in location.onLocationChanged) {
if (location.isNotNull) {
yield LocationState.sendData(location: updateLocation(location));
}
}
//send one initial update to change state
yield LocationState.sendData(
location: updateLocation(await Location().getLocation()));
}
This tracker is for issues related to:
-
Dart core libraries ("dart:async", "dart:io", etc.)
-
Dart SDK Version 2.8.4
-
Windows, MacOSX, and Linux
MatrixDev and saibotma
Metadata
Metadata
Assignees
Labels
P4area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-warningIssues with the analyzer's Warning codesIssues with the analyzer's Warning codestype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug