After building the application, a crash occurs at the MacOS level when starting the application.
I updated to macos_ui 2.0. And I built the application. The build completes normally, but a MacOS-level crash occurs when starting the app.
The RUN console displays the following message: ”Could not cast value of type 'my App.BlurryContainerViewController' (0x1046468b0) to 'FlutterViewController' (0x1098f2d20).”
It seems that the crash occurs during the "config.apply()" process in the following code.
”Future
Even after updating to macos_ui2.02, the same crash occurs.
When I investigated, the contents of macos/Runner/MainFlutterWindow.swift file remained the same as when macos_ui 1.3.0 was used. There was a description of "class BlurryContainerViewController". (see macos_ui 1.3.0 https://pub.dev/packages/macos_ui/versions/1.3.0)
In another working application using macos_ui2.02, the contents of the macos/Runner/MainFlutterWindow.swift file were as follows:
”import Cocoa import FlutterMacOS
class MainFlutterWindow: NSWindow { override func awakeFromNib() { let flutterViewController = FlutterViewController.init() let windowFrame = self.frame self.contentViewController = flutterViewController self.setFrame(windowFrame, display: true)
RegisterGeneratedPlugins(registry: flutterViewController)
super.awakeFromNib()
} }”
When I replaced the MainFlutterWindow.swift file of the crashed application with the above code and built it, the crash did not occur.
Was my treatment good? Is there anything else I need to do? Please let me know.
Yeah, 2.0.0 was a pretty major release which introduced breaking changes. The window is now no longer styled through modifications to the MainFlutterWindow.swift file, but instead relies on macos_window_utils, so make sure your MainFlutterWindow.swift file looks like this:
import Cocoa
import FlutterMacOS
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let flutterViewController = FlutterViewController.init()
let windowFrame = self.frame
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)
RegisterGeneratedPlugins(registry: flutterViewController)
super.awakeFromNib()
}
}