Skip to content

Commit

Permalink
assgin _savedLocale = locale when _saveLocale(); notify listeners aft…
Browse files Browse the repository at this point in the history
…er _saveLocale becaused it's needed by the ui
  • Loading branch information
l authored and l committed May 4, 2024
1 parent 066c7c4 commit 7a9121d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/src/easy_localization_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,15 @@ class EasyLocalizationController extends ChangeNotifier {

Future<void> setLocale(Locale l) async {
_locale = l;
await loadTranslations();
notifyListeners();
EasyLocalization.logger('Locale $locale changed');
await _saveLocale(_locale);
await loadTranslations();
notifyListeners();
}

Future<void> _saveLocale(Locale? locale) async {
if (!saveLocale) return;
_savedLocale = locale;
final preferences = await SharedPreferences.getInstance();
await preferences.setString('locale', locale.toString());
EasyLocalization.logger('Locale $locale saved');
Expand Down

0 comments on commit 7a9121d

Please sign in to comment.