如何在Flutter应用上为iOS创建自定义视图

时间:2018-07-29 22:21:20

标签: ios swift flutter

我希望能够在按下按钮时为iOS创建自定义屏幕(viewController和Storyboard)。

我有一个方法频道:

static const channel = const MethodChannel('myChannel');

在flutter应用程序的main.dart文件中有一个功能:

Future <Null> launchCustomView() async {
   if(Platform.isIOS) {
      try {
        await channel.invokeMethod('startCustomView');
      } on PlatformException {}
   }
}
我在特定条件下(按下RaisedButton时)调用的

。 在AppDelegate.swift中,我有以下内容:

override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {GeneratedPluginRegistrant.register(with: self)


    var controller : FlutterViewController = window?.rootViewController as! FlutterViewController;
    let channel = FlutterMethodChannel.init(name: "myChannel", binaryMessenger: controller);

    channel.setMethodCallHandler({(call: FlutterMethodCall, result: FlutterResult) -> Void in
        if ("startCustomView" == call.method) {
            // Load a new view
        } else {
            result(FlutterMethodNotImplemented);
        }
    });

如果我有一个故事板和一个视图控制器,如何显示这些而不是flutter / dart小部件?

0 个答案:

没有答案