Flutter both directions of platform channel call? [duplicate]

五迷三道 提交于 2019-12-02 07:30:08

问题


According to current documentation of flutter platfrom channel it seems only possible to call host (Native) from client (Dart) and then we get response from host. Is there any possiblity of its reverse, e.g. to call directly Client from host?


回答1:


Yes, this is possible using MethodChannel.

You will to specify a call handler on your method channel by using setMethodCallHandler.

As an example, the Java version of MethodChannel has the invokeMethod method just like the Dart class has. This means that you can use invokeMethod on all platform. If you are calling it from native, you will have to set a method call handler in Flutter and vise versa.
On iOS it is exactly the same.



来源:https://stackoverflow.com/questions/56201503/flutter-both-directions-of-platform-channel-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!