I'm working on a Flutter app with some native kotlin code. It's straightforward to call native methods from Flutter through the MethodChannel, and vice-versa (from MainActivity).
However, I also want a way to trigger Flutter code triggered from a native Broadcast receiver, where I don't have the original MethodChannel. The problem is, I'm not sure how to create a FlutterEngine with the right arguments to get access to the same MethodChannel.
Is there a way to construct the same FlutterEngine that can be used to call back into Flutter code? What I want to do:
var flutterEngine = FlutterEngine(XXX)
var flutterChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, FLUTTER_CHANNEL)
flutterChannel.invokeMethod(...)
I'm not sure what XXX
should be here to get the same Channel I have in MainActivity. If there's some info I need to pass from MainActivity, I could use intents to pass it to my broadcast receiver, but it's not clear what is needed.