bitsdojo_window
bitsdojo_window copied to clipboard
No window found when setup bitsdojo_window on macOS
Environment
macOS 14.2 Intel based
Flutter 3.16.9
Here's the issue:
I set the MainFlutterWindow.swift file as below:
import Cocoa
import FlutterMacOS
import bitsdojo_window_macos
class MainFlutterWindow: BitsdojoWindow {
override func bitsdojo_window_configure() -> UInt {
// pay attention to this line
return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
}
override func awakeFromNib() {
let flutterViewController = FlutterViewController()
let windowFrame = self.frame
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)
RegisterGeneratedPlugins(registry: flutterViewController)
super.awakeFromNib()
}
}
and the main.dart as below:
import 'package:bitsdojo_window/bitsdojo_window.dart';
// other imports
void main() {
runApp(MyApp());
doWhenWindowReady(() {
appWindow.minSize = Size(800, 700);
appWindow.size = Size(800, 700);
appWindow.maxSize=Size(800, 700);
appWindow.alignment = Alignment.center;
appWindow.show();
});
}
// ...
If I set like this, no window will be found on macOS (I think it Initialized, but no window, although I click the app icon on dock) *
Then I found readme document says:
If you don't want to hide the window on startup, you can remove the BDW_HIDE_ON_STARTUP flag from the code above.
But if I remove BDW_HIDE_ON_STARTUP, it has another issue: The window will be the wrong size and black on startup for 1 sec and then load the content **
* By the way, I find if I click the app's menu on macOS, the window will be shown ** Release mode, debug mode will be longer time
Expect effect:
hide the default window -> wait for custom window style -> show window
Same, window not showing after .show()
According to my test, it's a new version issue. Previous version (I tested Flutter 3.7.12) runs ok!
In my case, doWhenWindowReady will be triggered when the menu bar item is clicked.
In my case,
doWhenWindowReadywill be triggered when the menu bar item is clicked.
Yes, I mentioned it
By the way, I find if I click the app's menu on macOS, the window will be shown
But it's not the way I want, and I have to use Flutter^3.7 when develop Flutter desktop apps to avoid this issue.
Had the same issue with flutter 3.16.9 and 3.19.3. it works fine in 3.13.9
My App starts but doWhenWindowReady is never called.
if I try the temporary solution https://github.com/bitsdojo/bitsdojo_window/issues/238#issuecomment-1868308533 my app crashes
for me it works again with flutter 3.22.0
for me it works again with flutter 3.22.0
Flutter adapt to bitsdojo_window 😂