0

I have code that starts iOS SDK, launches new screen and returns result in delegate.

This is how I start SDK that launches its screen

let myChannel = FlutterMethodChannel(name: "samples.flutter.dev/channel", binaryMessenger: controller.binaryMessenger)

myChannel.setMethodCallHandler { (call, result) in
    if call.method == "myChannel" {
        let router = ViewRouter()
        router.delegate = controller
        self.navigationController?.pushViewController(UIHostingController(rootView: ContentViewQID().environmentObject(router)), animated: false)
        
        // Need to recieve result here and send it to flutter
        // result("here need to be result")
        
    }
}

And this is where I get the result

extension FlutterViewController : FinalResultDelegate {
    
 public func result(opticalResult: OpticalResult?,
                        electronicResult: ElectronicResult?,
                        finalResult: FinalResult?) {
     
        guard let opticalResult = opticalResult,
        let electronicResult = electronicResult,
        let finalResult = finalResult else {
            return
        }
        
        // Currently recieving the result here
    }

}

And I don't understand how can I send result from FlutterViewController extension to Flutter

Vladyslav
  • 11
  • 1
  • Why not call a Dart method from native? https://stackoverflow.com/questions/54708249/how-to-send-data-back-from-ios-to-flutter/54714313#54714313 – Richard Heap Mar 29 '22 at 15:12
  • Inside your setMethodCallHandler you should access your result function from FlutterViewController and pass the returned object as result() inside setMethodCallHandler. You could also try to use EventChannel to make it more reactive – Julian Modlinski Mar 29 '22 at 15:17

0 Answers0