I was trying to make a stream function that returns LocationData
as stream.
But I got this error saying
A yielded value of type 'Stream<LocationData>' must be assignable to 'LocationData'
Stream<LocationData> getCoordinates() async* {
yield Location.instance.onLocationChanged;//error shows here
}
CodePudding user response:
According to your error message, you are missing a *
after your yield
to actually yield each item in your stream:
Stream<LocationData> getCoordinates() async* {
yield* Location.instance.onLocationChanged;
}
Please note that this is an educated guess, next time it would really help to have more code.