5

How do you access the FlutterBinaryMessenger in the AppDelegate on the Swift side of a MacOS Flutter application? In all the examples I have found, the AppDelegate is just a placeholder. You need to get the FlutterBinaryMessenger to instantiate a FlutterMethodChannel to actually communicate to the Dart side.

1 Answer 1

4

In the current macOS template, the FlutterViewController (which lets you get the messenger, via .engine.binaryMessenger) is owned by the window, not the application. If you want to access it from the AppDelegate you'll need to wire up a connection between AppDelegate and MainFlutterWindow.

1
  • I had to modify the MainFlutterWindow.swift file to store the FlutterViewController in a static variable (horrible on both counts, I know) but it did work.
    – Boggle
    Mar 26, 2020 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.