mapEventToState method
Must be implemented when a class extends BidirectionalBloc.
mapEventToState
is called whenever an event is added and will convert
that event into a new BloC state. It can yield zero, one or several states
for an event.
Implementation
@override
Stream<FastDeviceOrientationBlocState> mapEventToState(
FastDeviceOrientationBlocEvent event,
) async* {
if (event.type == FastDeviceOrientationBlocEventType.changed) {
final orientation = event.payload as Orientation;
if (orientation != currentState.orientation) {
_logger.debug('Device orientation changed to ${orientation.name}');
yield currentState.copyWith(orientation: orientation);
}
}
}