flutter build ios-framework
lazy var flutterEngine = FlutterEngine(name: "my flutter engine")
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Runs the default Dart entrypoint with a default Flutter route.
flutterEngine.run();
// Connects plugins with iOS platform code to this app.
GeneratedPluginRegistrant.register(with: self.flutterEngine);
return true;
}
let flutterEngine = (UIApplication.shared.delegate as! AppDelegate).flutterEngine
let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
// 全螢幕
flutterViewController.modalPresentationStyle = .fullScreen
// 清空之前的 viewController
flutterEngine.viewController = nil
// 設定初始化頁面的 Router
flutterEngine.navigationChannel.invokeMethod("pushRoute", arguments: "/detail")
// 設定 MethodChannel,實作 closePage
let channel = FlutterMethodChannel(name: "com.swimple.channel", binaryMessenger: flutterViewController.binaryMessenger)
channel.setMethodCallHandler { (call: FlutterMethodCall, result: FlutterResult) -> Void in
if call.method == "closePage" {
flutterViewController.dismiss(animated: true, completion: nil)
}
}
// 透過 Present Model 呈現
present(flutterViewController, animated: true, completion: nil)
<key>NSCameraUsageDescription</key>
<string>Allow access to camera</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow access to microphone for video recording</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allow access to photo library</string>