bitsdojo_window icon indicating copy to clipboard operation
bitsdojo_window copied to clipboard

No window found when setup bitsdojo_window on macOS

Open Zhoucheng133 opened this issue 1 year ago • 5 comments

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

Zhoucheng133 avatar Feb 06 '24 01:02 Zhoucheng133

Same, window not showing after .show()

suxoikorm avatar Feb 08 '24 22:02 suxoikorm

According to my test, it's a new version issue. Previous version (I tested Flutter 3.7.12) runs ok!

Zhoucheng133 avatar Feb 10 '24 10:02 Zhoucheng133

In my case, doWhenWindowReady will be triggered when the menu bar item is clicked.

gitbobobo avatar Feb 14 '24 08:02 gitbobobo

In my case, doWhenWindowReady will 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.

Zhoucheng133 avatar Feb 15 '24 07:02 Zhoucheng133

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

marcosgcd avatar Mar 12 '24 12:03 marcosgcd

for me it works again with flutter 3.22.0

marcosgcd avatar May 16 '24 08:05 marcosgcd

for me it works again with flutter 3.22.0

Flutter adapt to bitsdojo_window 😂

Zhoucheng133 avatar May 16 '24 10:05 Zhoucheng133