mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix Platform.localeName by setting _Platform._localeClosure (flutter/engine#4450)
This commit is contained in:
parent
9e95f34064
commit
e2bb119248
@ -112,16 +112,20 @@ static void InitDartAsync(Dart_Handle builtin_library,
|
||||
&schedule_microtask));
|
||||
}
|
||||
|
||||
static void InitDartIO(const std::string& script_uri) {
|
||||
static void InitDartIO(Dart_Handle builtin_library,
|
||||
const std::string& script_uri) {
|
||||
Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
|
||||
DART_CHECK_VALID(io_lib);
|
||||
Dart_Handle platform_type =
|
||||
Dart_GetType(io_lib, ToDart("_Platform"), 0, nullptr);
|
||||
DART_CHECK_VALID(platform_type);
|
||||
if (!script_uri.empty()) {
|
||||
Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
|
||||
DART_CHECK_VALID(io_lib);
|
||||
Dart_Handle platform_type =
|
||||
Dart_GetType(io_lib, ToDart("_Platform"), 0, nullptr);
|
||||
DART_CHECK_VALID(platform_type);
|
||||
DART_CHECK_VALID(Dart_SetField(platform_type, ToDart("_nativeScript"),
|
||||
ToDart(script_uri)));
|
||||
}
|
||||
Dart_Handle locale_closure = GetClosure(builtin_library, "_getLocaleClosure");
|
||||
DART_CHECK_VALID(
|
||||
Dart_SetField(platform_type, ToDart("_localeClosure"), locale_closure));
|
||||
}
|
||||
|
||||
void DartRuntimeHooks::Install(IsolateType isolate_type,
|
||||
@ -131,7 +135,7 @@ void DartRuntimeHooks::Install(IsolateType isolate_type,
|
||||
InitDartInternal(builtin, isolate_type);
|
||||
InitDartCore(builtin, script_uri);
|
||||
InitDartAsync(builtin, isolate_type);
|
||||
InitDartIO(script_uri);
|
||||
InitDartIO(builtin, script_uri);
|
||||
}
|
||||
|
||||
// Implementation of native functions which are used for some
|
||||
|
||||
@ -39,6 +39,12 @@ void _updateWindowMetrics(double devicePixelRatio,
|
||||
_invoke(window.onMetricsChanged, window._onMetricsChangedZone);
|
||||
}
|
||||
|
||||
typedef String LocaleClosure();
|
||||
|
||||
String _localeClosure() => window._locale.toString();
|
||||
|
||||
LocaleClosure _getLocaleClosure() => _localeClosure;
|
||||
|
||||
void _updateLocale(String languageCode, String countryCode) {
|
||||
window._locale = new Locale(languageCode, countryCode);
|
||||
_invoke(window.onLocaleChanged, window._onLocaleChangedZone);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
dart:_internal,::,_printClosure
|
||||
dart:async,::,_setScheduleImmediateClosure
|
||||
dart:io,::,_setupHooks
|
||||
dart:io,_Platform,_localeClosure
|
||||
dart:io,_Platform,set:_nativeScript
|
||||
dart:isolate,::,_getIsolateScheduleImmediateClosure
|
||||
dart:isolate,::,_setupHooks
|
||||
@ -12,6 +13,7 @@ dart:ui,::,_dispatchSemanticsAction
|
||||
dart:ui,::,_drawFrame
|
||||
dart:ui,::,_getGetBaseURLClosure
|
||||
dart:ui,::,_baseURL
|
||||
dart:ui,::,_getLocaleClosure
|
||||
dart:ui,::,_getMainClosure
|
||||
dart:ui,::,_getPrintClosure
|
||||
dart:ui,::,_getScheduleMicrotaskClosure
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user