fix: update LocaleBloc and LocaleRepositoryImpl to use named parameters for better clarity
This commit is contained in:
@@ -55,7 +55,7 @@ class LocaleBloc extends Bloc<LocaleEvent, LocaleState> {
|
|||||||
final Locale? savedLocale = await getLocaleUseCase();
|
final Locale? savedLocale = await getLocaleUseCase();
|
||||||
final Locale locale = savedLocale ?? const Locale('es');
|
final Locale locale = savedLocale ?? const Locale('es');
|
||||||
|
|
||||||
LocaleSettings.setLocaleRaw(locale.languageCode);
|
await LocaleSettings.setLocaleRaw(locale.languageCode);
|
||||||
|
|
||||||
emit(LocaleState(locale: locale, supportedLocales: state.supportedLocales));
|
emit(LocaleState(locale: locale, supportedLocales: state.supportedLocales));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,19 +7,19 @@ import '../datasources/locale_local_data_source.dart';
|
|||||||
/// This class handles the mapping between domain [Locale] objects and the raw
|
/// This class handles the mapping between domain [Locale] objects and the raw
|
||||||
/// strings handled by the [LocaleLocalDataSource].
|
/// strings handled by the [LocaleLocalDataSource].
|
||||||
class LocaleRepositoryImpl implements LocaleRepositoryInterface {
|
class LocaleRepositoryImpl implements LocaleRepositoryInterface {
|
||||||
final LocaleLocalDataSource _localDataSource;
|
/// Creates a [LocaleRepositoryImpl] with the provided [localDataSource].
|
||||||
|
LocaleRepositoryImpl({required this.localDataSource});
|
||||||
|
|
||||||
/// Creates a [LocaleRepositoryImpl] with the provided [_localDataSource].
|
final LocaleLocalDataSource localDataSource;
|
||||||
LocaleRepositoryImpl(this._localDataSource);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> saveLocale(Locale locale) {
|
Future<void> saveLocale(Locale locale) {
|
||||||
return _localDataSource.saveLanguageCode(locale.languageCode);
|
return localDataSource.saveLanguageCode(locale.languageCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Locale?> getSavedLocale() async {
|
Future<Locale?> getSavedLocale() async {
|
||||||
final String? languageCode = await _localDataSource.getLanguageCode();
|
final String? languageCode = await localDataSource.getLanguageCode();
|
||||||
if (languageCode != null) {
|
if (languageCode != null) {
|
||||||
return Locale(languageCode);
|
return Locale(languageCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class LocalizationModule extends Module {
|
|||||||
|
|
||||||
// Repositories
|
// Repositories
|
||||||
i.addLazySingleton<LocaleRepositoryInterface>(
|
i.addLazySingleton<LocaleRepositoryInterface>(
|
||||||
() => LocaleRepositoryImpl(i.get<LocaleLocalDataSource>()),
|
() => LocaleRepositoryImpl(localDataSource: i.get<LocaleLocalDataSource>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Use Cases
|
// Use Cases
|
||||||
|
|||||||
Reference in New Issue
Block a user