From 6585f334a1cc272e6faf471d738f2b9ebeb10265 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Wed, 6 Feb 2019 15:29:19 -0800 Subject: [PATCH] Allow all entrypoints support by the command line VM. (#7717) --- lib/ui/hooks.dart | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/ui/hooks.dart b/lib/ui/hooks.dart index 3f536d2fa..b1550bf90 100644 --- a/lib/ui/hooks.dart +++ b/lib/ui/hooks.dart @@ -168,12 +168,26 @@ void _drawFrame() { _invoke(window.onDrawFrame, window._onDrawFrameZone); } +// ignore: always_declare_return_types, prefer_generic_function_type_aliases +typedef _UnaryFunction(Null args); +// ignore: always_declare_return_types, prefer_generic_function_type_aliases +typedef _BinaryFunction(Null args, Null message); + @pragma('vm:entry-point') // ignore: unused_element void _runMainZoned(Function startMainIsolateFunction, Function userMainFunction) { startMainIsolateFunction((){ runZoned>(() { - userMainFunction(); + const List empty_args = []; + if (userMainFunction is _BinaryFunction) { + // This seems to be undocumented but supported by the command line VM. + // Let's do the same in case old entry-points are ported to Flutter. + (userMainFunction as dynamic)(empty_args, ''); + } else if (userMainFunction is _UnaryFunction) { + (userMainFunction as dynamic)(empty_args); + } else { + userMainFunction(); + } }, onError: (Object error, StackTrace stackTrace) { _reportUnhandledException(error.toString(), stackTrace.toString()); }); -- GitLab