File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -166,10 +166,14 @@ class ThemeModel with ChangeNotifier {
166
166
String ? _locale;
167
167
String ? get locale => _locale;
168
168
169
- Future <void > setLocale (String v) async {
169
+ Future <void > setLocale (String ? v) async {
170
170
_locale = v;
171
171
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
+ }
173
177
notifyListeners ();
174
178
}
175
179
Original file line number Diff line number Diff line change @@ -86,13 +86,13 @@ class SettingsScreen extends StatelessWidget {
86
86
? AppLocalizations .of (context)! .followSystem
87
87
: localeNameMap[key],
88
88
onTap: (_) async {
89
- final res = await ( theme.showConfirm (
89
+ final res = await theme.showConfirm (
90
90
context,
91
91
Text (
92
92
'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);
96
96
auth.reloadApp ();
97
97
}
98
98
},
You can’t perform that action at this time.
0 commit comments