Flutter在我尝试使用UniversalLink打开应用程序时导致应用程序崩溃。

huangapple go评论86阅读模式
英文:

Flutter is crashing my application when I try to open it with a UniversalLink

问题

我试图打开特定的FlutterViewController,当我关闭我的应用程序并尝试使用通用链接打开它时,应用程序会捕获此异常:

Flutter视图控制器 'NSInternalInconsistencyException',原因:'引擎是必需的'。
但是,我已经在我的AppDelegate中初始化了Flutter引擎

override func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
    self.flutterStart()
    return true
}

func flutterStart() {
    flutterEngine.run()
    // 将插件连接到此应用程序的iOS平台代码。
    GeneratedPluginRegistrant.register(with: self.flutterEngine);
}

如果应用程序已经打开,一切看起来都很好。

请使用dispatch main async。
检查函数是否已调用,如果尚未调用,则在创建FlutterViewController时调用它。

英文:

Im trying to open a specific FlutterViewController, when I close my application and try to open it with a universal link the application catch this exception:
Flutter view controller 'NSInternalInconsistencyException', reason: 'Engine is required'.
but im already initialized the flutter engine here in my AppDelegate.


    override func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        self.flutterStart()
        return true
    }

    func flutterStart() {
        flutterEngine.run()
        // Connects plugins with iOS platform code to this app.
        GeneratedPluginRegistrant.register(with: self.flutterEngine);
}

if the app is already open everything looks good.

Use dispatch main async.
check if de function is already called and if not i call it when i create the FlutterViewController.

答案1

得分: 0

问题在于我试图在调试模式下运行Flutter应用程序:

FLUTTER_BUILD_MODE = debug

为了解决这个问题,我只是将其更改为 release

英文:

The problems was that I was trying to run the app with flutter in debug mode:

FLUTTER_BUILD_MODE = debug

To solve the issue I just changed it to release.

huangapple
  • 本文由 发表于 2023年7月28日 04:21:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76783159.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定