[flutter_tools] For l10n with deferred loading, use loadLibrary for non-web too (#59539)
After Dart VM change we are now required to use loadLibrary on an import whenever it is imported as deferred. See: https://dart-review.googlesource.com/c/sdk/+/149613
This commit is contained in:
@@ -217,19 +217,6 @@ const String lookupFunctionTemplate = '''
|
||||
}''';
|
||||
|
||||
const String lookupFunctionDeferredLoadingTemplate = '''
|
||||
/// Lazy load the library for web, on other platforms we return the
|
||||
/// localizations synchronously.
|
||||
Future<@(class)> _loadLibraryForWeb(
|
||||
Future<dynamic> Function() loadLibrary,
|
||||
@(class) Function() localizationClosure,
|
||||
) {
|
||||
if (kIsWeb) {
|
||||
return loadLibrary().then((dynamic _) => localizationClosure());
|
||||
} else {
|
||||
return SynchronousFuture<@(class)>(localizationClosure());
|
||||
}
|
||||
}
|
||||
|
||||
Future<@(class)> @(lookupName)(Locale locale) {
|
||||
@(lookupBody)
|
||||
assert(false, '@(class).delegate failed to load unsupported locale "\$locale"');
|
||||
@@ -243,7 +230,7 @@ const String lookupBodyTemplate = '''@(lookupAllCodesSpecified)
|
||||
|
||||
const String switchClauseTemplate = '''case '@(case)': return @(localeClass)();''';
|
||||
|
||||
const String switchClauseDeferredLoadingTemplate = '''case '@(case)': return _loadLibraryForWeb(@(library).loadLibrary, () => @(library).@(localeClass)());''';
|
||||
const String switchClauseDeferredLoadingTemplate = '''case '@(case)': return @(library).loadLibrary().then((dynamic _) => @(library).@(localeClass)());''';
|
||||
|
||||
const String nestedSwitchTemplate = '''case '@(languageCode)': {
|
||||
switch (locale.@(code)) {
|
||||
|
||||
Reference in New Issue
Block a user