appThemeModule function
Implementation
Future<void> appThemeModule({required List<AppTheme> themes}) async {
// datasource
themeLocator.registerSingleton<AppThemePreferences>(AppThemePreferencesImpl(await SharedPreferences.getInstance()));
// repository
themeLocator.registerSingleton<AppThemeRepository>(AppThemeRepositoryImpl(themeLocator()));
// use cases
themeLocator.registerSingleton(GetAppThemeUseCase(themeLocator()));
themeLocator.registerSingleton(SaveAppThemeUseCase(themeLocator()));
// bloc
final initialTheme = themeLocator<GetAppThemeUseCase>().execute(
themes,
platformBrightness: WidgetsBinding.instance.platformDispatcher.platformBrightness,
);
themeLocator.registerSingleton(
AppThemeBloc(themeLocator(), initialTheme: initialTheme),
dispose: (bloc) => bloc.close(),
);
}