Run a method or function in dart when a callback from native android methodchannel Run a method or function in dart when a callback from native android methodchannel dart dart

Run a method or function in dart when a callback from native android methodchannel


The way platform channels work is the Flutter app executes a method to run platform-specific code. The Flutter app then waits for a callback to be made that can then be handled.

You may want to narrow down the scope that you're trying to achieve in this question. Like when do you intend to call sendData() from platform-specific code? Do you expect to listen for notifications like firebase_messaging? If you'd like to run tasks in the background using Flutter, you may want to look into using Isolate.