Closed Racinggavin closed 1 year ago
I just resolved the problem by manually modify the generated files. It's the latest commit of my github repro.
S _lookupS(Locale locale) {
final name = (locale.countryCode?.isEmpty ?? false)
? locale.languageCode
: locale.toString();
String localeName = Intl.canonicalizedLocale(name);
if(!initializeMessagesSync(localeName)) {
localeName = 'en';
}
Intl.defaultLocale = localeName;
final instance = S();
S._current = instance;
return instance;
}
static Future<S> load(Locale locale) {
return SynchronousFuture<S>(_lookupS(locale));
}
bool initializeMessagesSync(String localeName) {
var availableLocale = Intl.verifiedLocale(
localeName, (locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null);
if (availableLocale == null) {
return false;
}
initializeInternalMessageLookup(() => new CompositeMessageLookup());
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
return true;
}
Hi @Racinggavin,
Thanks for reporting this!
I've checked the attached sample, and you are right. Indeed there is some strange behavior (black screen) during the async load of localization messages.
According to the issue, it seems that this has something with the MaterialApp
and its implementation of loading localizations.
Regarding the proposed modification, it will work well in case the use_deferred_loading
is disabled (default behavior). However, I'm not sure that it will work for others that have this setting enabled.
Anyway, thanks for the workaround until this issue is resolved.
@lzoran, since it doesn't look like https://github.com/flutter/flutter/issues/87926 is receiving much attention, would you consider incorporating @Racinggavin's workaround as part of the code generation (maybe as an opt-in setting)? It's easy to forget to manually update these files every time they get regenerated.
This should be fixed with the Flutter Intl 1.19.0
extension and the intl_utils 2.8.1
package that is used under the hood for generating the localization files.
I'm closing this issue as resolved. In case you detect any irregularity, feel free to reopen it.
my observation as the github repository here