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<FastThemeBlocState> mapEventToState(FastThemeBlocEvent event) async* {
if (event.type == FastThemeBlocEventType.light) {
yield FastThemeBlocState(
brightness: Brightness.light,
themeMode: ThemeMode.light,
);
} else if (event.type == FastThemeBlocEventType.dark) {
yield FastThemeBlocState(
brightness: Brightness.dark,
themeMode: ThemeMode.dark,
);
} else {
yield FastThemeBlocState(
brightness:
WidgetsBinding.instance.platformDispatcher.platformBrightness,
themeMode: ThemeMode.system,
);
}
}