قالب وردپرس درنا توس
Home / IOS Development / ios – Open native UIViewController in Flutter

ios – Open native UIViewController in Flutter



I have an application I develop in Flutter and it has a UIViewController that needs to be implemented in native IOS (there is no other solution, it is a must)

I have implemented it, it works according to the first test , but I would like to double check if it is unwanted in your opinion, as I am not so experienced in Flutter, and I am scared to do some clutter in my app navigation bar that may lead to errors in the future.

So, I have implemented it by MethodChannel. I have a method called "Flutter page". I don't paste MethodChannel related stuff here, as they are trivial.

In appDelegate didFinishLaunchingWithOptions I added this:

  let flutterViewController = FlutterViewController ()
self.navigationController = UINavigationController (rootViewController: flutterViewController)
self.navigationController? .isNavigationBarHidden = true

self.window = UIWindow (frame: UIScreen.main.bounds)
self.window.rootViewController = self.navigationController
self.window.makeKeyAndVisible ()

And my open method like this:

  private func openNativeUI (result: FlutterResult) {
leave sb = UIStoryboard (name: "Main", bundle: null)
la uiController = sb.instantiateViewController (withIdentifier: "nativeui")

self.navigationController? .pushViewController (uiController, animated: true)

result (true)
}

What do you think?

Any advice is highly appreciated and thank you for your assistance in advance!


Source link