One approach is to create a new FlutterEngine that doesn't call into UI code, when MainActivity
is terminated, but when a foreground service notification is still active. You'll still need to refactor you code so the FlutterEngine is the one always making MethodChannel
calls.
Here's an example.