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 locale = savedLocale ?? const Locale('es');
|
||||
|
||||
LocaleSettings.setLocaleRaw(locale.languageCode);
|
||||
await LocaleSettings.setLocaleRaw(locale.languageCode);
|
||||
|
||||
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
|
||||
/// strings handled by the [LocaleLocalDataSource].
|
||||
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].
|
||||
LocaleRepositoryImpl(this._localDataSource);
|
||||
final LocaleLocalDataSource localDataSource;
|
||||
|
||||
@override
|
||||
Future<void> saveLocale(Locale locale) {
|
||||
return _localDataSource.saveLanguageCode(locale.languageCode);
|
||||
return localDataSource.saveLanguageCode(locale.languageCode);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Locale?> getSavedLocale() async {
|
||||
final String? languageCode = await _localDataSource.getLanguageCode();
|
||||
final String? languageCode = await localDataSource.getLanguageCode();
|
||||
if (languageCode != null) {
|
||||
return Locale(languageCode);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class LocalizationModule extends Module {
|
||||
|
||||
// Repositories
|
||||
i.addLazySingleton<LocaleRepositoryInterface>(
|
||||
() => LocaleRepositoryImpl(i.get<LocaleLocalDataSource>()),
|
||||
() => LocaleRepositoryImpl(localDataSource: i.get<LocaleLocalDataSource>()),
|
||||
);
|
||||
|
||||
// Use Cases
|
||||
|
||||
Reference in New Issue
Block a user