Skip to content

Commit 9b3a6fc

Browse files
committed
fix: set locale null
1 parent e2f103a commit 9b3a6fc

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/models/theme.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,14 @@ class ThemeModel with ChangeNotifier {
166166
String? _locale;
167167
String? get locale => _locale;
168168

169-
Future<void> setLocale(String v) async {
169+
Future<void> setLocale(String? v) async {
170170
_locale = v;
171171
final prefs = await SharedPreferences.getInstance();
172-
await prefs.setString(StorageKeys.locale, v);
172+
if (v == null) {
173+
await prefs.remove(StorageKeys.locale);
174+
} else {
175+
await prefs.setString(StorageKeys.locale, v);
176+
}
173177
notifyListeners();
174178
}
175179

lib/screens/settings.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ class SettingsScreen extends StatelessWidget {
8686
? AppLocalizations.of(context)!.followSystem
8787
: localeNameMap[key],
8888
onTap: (_) async {
89-
final res = await (theme.showConfirm(
89+
final res = await theme.showConfirm(
9090
context,
9191
Text(
9292
'The app will reload to make the language setting take effect'),
93-
) as Future<bool>);
94-
if (res && theme.locale != key) {
95-
await theme.setLocale(key!);
93+
);
94+
if (res == true && theme.locale != key) {
95+
await theme.setLocale(key);
9696
auth.reloadApp();
9797
}
9898
},

0 commit comments

Comments
 (0)