@@ -27,8 +27,8 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
27
27
];
28
28
}
29
29
30
- LocaleListResolutionCallback listResolution({Locale fallback}) {
31
- return (List<Locale> locales, Iterable<Locale> supported) {
30
+ LocaleListResolutionCallback listResolution({Locale? fallback}) {
31
+ return (List<Locale>? locales, Iterable<Locale> supported) {
32
32
if (locales == null || locales.isEmpty) {
33
33
return fallback ?? supported.first;
34
34
} else {
@@ -37,51 +37,53 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
37
37
};
38
38
}
39
39
40
- LocaleResolutionCallback resolution({Locale fallback}) {
41
- return (Locale locale, Iterable<Locale> supported) {
40
+ LocaleResolutionCallback resolution({Locale? fallback}) {
41
+ return (Locale? locale, Iterable<Locale> supported) {
42
42
return _resolve(locale, fallback, supported);
43
43
};
44
44
}
45
45
46
- Locale _resolve(Locale locale, Locale fallback, Iterable<Locale> supported) {
46
+ Locale _resolve(Locale? locale, Locale? fallback, Iterable<Locale> supported) {
47
47
if (locale == null || !isSupported(locale)) {
48
48
return fallback ?? supported.first;
49
49
}
50
50
51
51
final Locale languageLocale = Locale(locale.languageCode, "");
52
52
if (supported.contains(locale)) {
53
53
return locale;
54
- } else if (supported.contains(languageLocale)) {
54
+ } else if (supported! .contains(languageLocale)) {
55
55
return languageLocale;
56
56
} else {
57
- final Locale fallbackLocale = fallback ?? supported.first;
57
+ final Locale fallbackLocale = fallback ?? supported! .first;
58
58
return fallbackLocale;
59
59
}
60
60
}
61
61
62
62
@override
63
- Future<S> load(Locale locale) {
64
- final String lang = getLang(locale);
63
+ Future<S> load(Locale? locale) {
64
+ final String? lang = getLang(locale);
65
65
if (lang != null) {
66
66
switch (lang) {
67
- @foreach{locale : locales} case "@{locale.value}": return SynchronousFuture<S>(const @{'$'}@{locale.value}());@end{'\n'}
67
+ case "en":
68
+ return SynchronousFuture<S>(const $en());
69
+ case "de":
70
+ return SynchronousFuture<S>(const $de());
68
71
default:
69
- // NO-OP.
72
+ // NO-OP.
70
73
}
71
74
}
72
75
return SynchronousFuture<S>(const S());
73
76
}
74
77
75
78
@override
76
- bool isSupported(Locale locale) =>
77
- locale != null && supportedLocales.contains(locale);
79
+ bool isSupported(Locale? locale) => locale != null && supportedLocales.contains(locale);
78
80
79
81
@override
80
82
bool shouldReload(GeneratedLocalizationsDelegate old) => false;
81
83
}
82
84
83
- String getLang(Locale l) => l == null
84
- ? null
85
- : l.countryCode != null && l.countryCode.isEmpty
86
- ? l.languageCode
87
- : l.toString();
85
+ String? getLang(Locale? l) => l == null
86
+ ? null
87
+ : l.countryCode != null && l.countryCode! .isEmpty
88
+ ? l.languageCode
89
+ : l.toString();
0 commit comments