flutter setInitialRoute: do not take effect

Outline

The need to achieve native flutter jump to specified routing page.

 

iOS projects found to be invalid FlutterViewController setInitialRouter, my demand is there: in engineering integration flutter iOS existing projects, then you can jump to any page of the business.

Among the examples of iOS page in two ways, as follows:

1. Examples of sub-:( invalid by the global unified way)

Swift Code:

    @objc func handleButtonAction() {
        let flutterEngine = (UIApplication.shared.delegate as? AppDelegate)?.flutterEngine
        let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)!
        flutterViewController.setInitialRoute("test1")

        self.navigationController?.pushViewController(flutterViewController, animated: true)
    }

This display is the best way, app is started, it will load the data directly, is what I need, and native rendering almost the same, there is no sense of violation and interaction is very smooth.

But if I want before jumping to a specific page, such as: "test1" Routing page, but found no effect ;

 

2, through the global unified pushrouter effective way :( poor results)

swift pushRouter:

  @objc func handleButtonAction() {
        let flutterEngine = (UIApplication.shared.delegate as? AppDelegate)?.flutterEngine
        let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)! 
       flutterViewController.pushRoute("test1")
        self.navigationController?.pushViewController(flutterViewController, animated: true)
    }

Although the above code is valid, but the effect is not very good, but a significant push state. So not what we want

3, provided by new FlutterViewController (active)

    @objc func handleButtonAction2(){
        let flutterViewController = FlutterViewController()
        flutterViewController.setInitialRoute("test1")
        
        self.navigationController?.pushViewController(flutterViewController, animated: true)
    }

Effective, but each has a flash rendering effects on an interactive than the native almost.

 

Guess you like

Origin www.cnblogs.com/kingbo/p/11237111.html