setLocale method
- String locale
Changes the app locale (language)
Implementation
Future<void> setLocale(String locale) async {
final old = state.locale;
emit(state.copyWith(locale: locale));
final result = await _repository.setLocale(locale);
result.fold(
(failure) => emit(state.copyWith(locale: old)),
(_) async {
// Also save to full preferences
await _repository.saveAppPreferences(state.toAppPreferences());
},
);
}