mirror of
https://github.com/git-touch/git-touch
synced 2025-02-02 08:56:54 +01:00
fix: set locale null
This commit is contained in:
parent
e2f103a807
commit
9b3a6fce07
@ -166,10 +166,14 @@ class ThemeModel with ChangeNotifier {
|
||||
String? _locale;
|
||||
String? get locale => _locale;
|
||||
|
||||
Future<void> setLocale(String v) async {
|
||||
Future<void> setLocale(String? v) async {
|
||||
_locale = v;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(StorageKeys.locale, v);
|
||||
if (v == null) {
|
||||
await prefs.remove(StorageKeys.locale);
|
||||
} else {
|
||||
await prefs.setString(StorageKeys.locale, v);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
@ -86,13 +86,13 @@ class SettingsScreen extends StatelessWidget {
|
||||
? AppLocalizations.of(context)!.followSystem
|
||||
: localeNameMap[key],
|
||||
onTap: (_) async {
|
||||
final res = await (theme.showConfirm(
|
||||
final res = await theme.showConfirm(
|
||||
context,
|
||||
Text(
|
||||
'The app will reload to make the language setting take effect'),
|
||||
) as Future<bool>);
|
||||
if (res && theme.locale != key) {
|
||||
await theme.setLocale(key!);
|
||||
);
|
||||
if (res == true && theme.locale != key) {
|
||||
await theme.setLocale(key);
|
||||
auth.reloadApp();
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user