chore: don't set l1 if locale is not valid (#3654)

This commit is contained in:
ggurdin 2025-08-07 12:04:15 -04:00 committed by GitHub
parent 867004243f
commit d1b7b13ab6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,18 +1,22 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart' as intl;
class LocaleProvider extends ChangeNotifier {
Locale? _locale;
Locale? get locale => _locale;
void setLocale(String? value) {
if (value == null || value.isEmpty) {
final split = value?.split('_');
if (split == null ||
split.isEmpty ||
!intl.DateFormat.localeExists(split[0])) {
_locale = null;
notifyListeners();
return;
}
final split = value.split('-');
_locale = Locale(split[0], split.length > 1 ? split[1] : null);
notifyListeners();
}