Skip to content

Commit

Permalink
Allow all entrypoints support by the command line VM. (flutter#7717)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde committed Feb 6, 2019
1 parent ce07399 commit 6585f33
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/ui/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Future<void>>(() {
userMainFunction();
const List<String> empty_args = <String>[];
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());
});
Expand Down

0 comments on commit 6585f33

Please sign in to comment.