fix: update LocaleBloc and LocaleRepositoryImpl to use named parameters for better clarity

This commit is contained in:
Achintha Isuru
2026-01-28 10:12:05 -05:00
parent ed588e0ec7
commit e73698e64f
3 changed files with 7 additions and 7 deletions

View File

@@ -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));
}

View File

@@ -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);
}

View File

@@ -24,7 +24,7 @@ class LocalizationModule extends Module {
// Repositories
i.addLazySingleton<LocaleRepositoryInterface>(
() => LocaleRepositoryImpl(i.get<LocaleLocalDataSource>()),
() => LocaleRepositoryImpl(localDataSource: i.get<LocaleLocalDataSource>()),
);
// Use Cases