Open matthew-carroll opened 12 months ago
I find the glitch isn’t really as noticeable when running the app in release mode (it’s really just a fraction of a second), though it is indeed noticeable at all.
It might be possible how add functionality to hide/unhide the window and document how to make sure the window is hidden during startup by modifying the app’s Swift code. This way you’d still be able to configure your app within Dart, while the only thing you’d need to do in Swift would be making sure the window is hidden during launch.
Is there a Swift and Dart code snippet that does what you described above? Or does this require new Dart APIs in this package?
Honestly, I am no longer quite sure if you can even hide the window programmatically, but you can make it invisible by setting its alpha value to 0. So, you could achieve what you’re trying to do like this:
In your MainFlutterWindow.swift
file in your Xcode project, add this line to the awakeFromNib
method, right above super.awakeFromNib()
:
self.alphaValue = 0.0
This will ensure that your window is opened with an alpha value of 0.0. Then, use the WindowManipulator
’s setWindowAlphaValue
method to set it to 1.0 in your Dart code at startup.
Adding the following line after the function awakeFromNib()
also works for hiding the app, though there's no method in this plugin to make it visible again, you need to add one in the plugin.
override public func order(_ place: NSWindow.OrderingMode, relativeTo otherWin: Int) {
super.order(place, relativeTo: otherWin)
super.setIsVisible(false)
}
(Adapted from window_manager
)
Oh, you’re right, I somehow missed the setVisible
method. Maybe I should expose that.
When setting the window size, background, etc, upon launch, there's a visual glitch because the window begins with the standard Flutter configuration and then switches to the desired configuration when the Dart application starts running.
This glitch can be avoided by coding the application delegate to set all of these properties on launch, but writing Swift in the XCode project largely eliminates the value of this package from a window configuration standpoint.
Is there anything that can be done about this initial glitch? Is there a way to avoid showing any window until the Dart app starts up, and therefore the Dart code can set the configuration before any window is visible?