I'm integrate Flutter module to ios Native project, I want to set Initial Route from ios native, but it not work, it use default route.
ViewController.swift
import UIKit
import Flutter
class ViewController: UIViewController {
let flutterEngine = FlutterEngine(name: "test")
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
flutterEngine.navigationChannel.invokeMethod("setInitialRoute", arguments:"/home")
flutterEngine.run();
}
@IBAction func handleClick(_ sender: Any) {
let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
flutterViewController.setInitialRoute("/home")
self.navigationController?.pushViewController(flutterViewController, animated: true)
}
}
main.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final _route = <String, WidgetBuilder>{
"/login": (context) => Login(),
"/home": (context) => Home()
};
@override
Widget build(BuildContext context) {
return MaterialApp(
routes: _route,
title: "App", // Title ของหน้า
home: Scaffold(
// หน้าจอหลัก
appBar: AppBar(
title: Text("App Navi"),
),
body: Login(),
),
);
}
}
Login, Home file please see in image, beacause stackoverflow can't to post text "It looks like your post is mostly code; please add some more details."



