侧边栏壁纸
  • 累计撰写 7 篇文章
  • 累计创建 0 个标签
  • 累计收到 2 条评论

目 录CONTENT

文章目录

Ios 集成 Flutter Frameworks

Haig
2022-04-06 / 0 评论 / 1 点赞 / 359 阅读 / 170 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-06-15,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

Ios 集成 Flutter Frameworks

使用命令生成 frameworks flutter build ios-framework --xcframework --no-universal

生成 App.xcframework 和 Flutter.xcframework

  1. 拖拽 frameworks 到你的应用 target 编译设置的 General > Frameworks, Libraries, and Embedded Content 下,然后在 Embed 下拉列表中选择 “Embed & Sign”。

  2. 初始化flutterEngine

import UIKit
import Flutter

@main
class AppDelegate: FlutterAppDelegate {
    lazy var flutterEngine = FlutterEngine(name: "hgg_im")


    override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
//        return true
        // Runs the default Dart entrypoint with a default Flutter route.
            flutterEngine.run();
            // Used to connect plugins (only if you have plugins with iOS platform code).
            return super.application(application, didFinishLaunchingWithOptions: launchOptions);
    }
}
  1. 启动页面

     let flutterEngine = (UIApplication.shared.delegate as! AppDelegate).flutterEngine
     let flutterViewController =
             FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
     //flutterViewController.modalPresentationStyle = UIModalPresentationStyle.fullScreen;
     present(flutterViewController, animated: true, completion: nil)
    
1
博主关闭了所有页面的评论