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
Bad state: Stream has already been listened to #70
Comments
Have you tried to close the Port and recreate it? Move the: to a function and call it to recreate the Port. |
From my code snippet above you can see that I do close the port in the stopGps2() function. I don't understand what you mean my "move to a function". The listener should be in a separate function from where the port is created? |
@sgalway00 you could do something like that: void _backgroundListener() { But my scenario is that i'm only activate the background_locator when my app go to INACTIVE state, so i have to create and recreate the port in certains conditions. |
Closing this issue due inactivity, but feel free to open it anytime; |
I have successfully implemented your package but when I try to start the isolate a second time I get an error "Bad state: Stream has already been listened to." During the first activation everything works as expected.
VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: Bad state: Stream has already been listened to. #0 _StreamController._subscribe (dart:async/stream_controller.dart:683:7) #1 _ControllerStream._createSubscription (dart:async/stream_controller.dart:833:19) #2 _StreamImpl.listen (dart:async/stream_impl.dart:475:9) #3 _ReceivePortImpl.listen (dart:isolate-patch/isolate_patch.dart:87:31) #4 GPSBloc.startGps2 package:yonav2/blocs/gpsBloc.dart:161 #5 _GpsSwitchState.build.<anonymous closure>.<anonymous closure> package:yonav2/gpsWidgets/gpsWidgets.dart:62 #6 _rootRunUnary (dart:async/zone.dart:1192:38) #7 _CustomZone.runUnary (dart:async/zone.dart:1085:19) #8 _FutureListener.handleValue (dart:async/future_impl.dart:141:18) #9 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45) #10 Future._propagateToListeners (dart:async/future_impl.dart:711:32) #11 Future._completeWithValue (dart:async/future_impl.da<…>
The text was updated successfully, but these errors were encountered: