How to call methods in Dart portion of the app, from the native platform using MethodChannel?

The signature is void setMethodCallHandler(Future<dynamic> handler(MethodCall call)), so we need to provide a function at the Dart end that returns Future<dynamic>, for example _channel.setMethodCallHandler(myUtilsHandler); Then implement the handler. This one handles two methods foo and bar returning respectively String and double. Future<dynamic> myUtilsHandler(MethodCall methodCall) async { switch (methodCall.method) { case ‘foo’: return ‘some string’; case … Read more