Using MethodChannel to invoke Flutter method from Kotlin

1,453 views
Skip to first unread message

Jeff W

unread,
Feb 28, 2018, 9:06:39 PM2/28/18
to Flutter Dev
Hi, I am modernizing an Android app UI to use Flutter for screen design.  My android app used the Google Nearby API to find local IOT devices.  Since there doesn't seem to be a package yet for the Nearby API, I was trying to use MethodChannel to start discovery, and I am able to successfully invoke methods in Kotlin from Flutter.  The problem is I now need to close the loop, and invoke Flutter methods from Kotlin Callback methods to pass data to show on the UI.  

In this Wiki page https://flutter.io/platform-channels/ it alludes to the fact that you can easily do the reverse "Note: If desired, method calls can also be sent in the reverse direction, with the platform acting as client to methods implemented in Dart."  But I am struggling to get it working.  Can anyone point me at a code example of Java / Kotlin calling into Flutter?

Thanks in advance

Todd Volkert

unread,
Mar 1, 2018, 1:09:30 AM3/1/18
to Jeff W, Flutter Dev
Hi Jeff,

Check out the quick_actions plugin, which shows you how to call from Java back into Dart.

Dart-side callback registration here.  Java-side method invocation here.

Cheers,
-T

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Jeff W

unread,
Mar 1, 2018, 10:40:33 AM3/1/18
to Flutter Dev
Thanks Todd
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages