handleInitEvent method

Stream<FastThemeBlocState> handleInitEvent(
  1. ThemeMode? mode
)

Handles the initialization event with an optional mode.

Implementation

Stream<FastThemeBlocState> handleInitEvent(ThemeMode? mode) async* {
  if (canInitialize) {
    _logger.debug('Initializing...');
    isInitializing = true;
    yield currentState.copyWith(isInitializing: true);

    WidgetsBinding.instance.platformDispatcher.onPlatformBrightnessChanged =
        onPlatformBrightnessChanged;

    if (mode == ThemeMode.light) {
      yield* handleLightEvent();
    } else if (mode == ThemeMode.dark) {
      yield* handleDarkEvent();
    } else {
      yield* handleSystemEvent();
    }

    addEvent(const FastThemeBlocEvent.initialized());
  }
}