setTripStateListener method

  1. @override
Stream<MoveTripState> setTripStateListener()
override

Set a block to be invoked every time SDK trip state changes. Returns stream: latest SDK trip state. Invoked every time SDK trip state changes.

Implementation

@override
Stream<MoveTripState> setTripStateListener() async* {
  yield* tripStateChannel
      .receiveBroadcastStream()
      .asyncMap<MoveTripState>((tripState) {
    MoveTripState? result = MoveTripState.values.firstWhereOrNull(
        (element) => element.name.toLowerCase() == tripState.toLowerCase());
    return result ?? MoveTripState.unknown;
  });
}