bitsdojo_window icon indicating copy to clipboard operation
bitsdojo_window copied to clipboard

appWindow.hide() behaviour changes from IDE to compiled EXE

Open boganiLuca opened this issue 1 year ago • 1 comments

I am developing an app that can run in two different ways, depending on args passed to it. One way has a GUI for configuring the app, the other way is supposed to be run as a Windows service and does its things depending on how it has been configured on the GUI side (this is just to give some context).

So, I basically have a flag set at runtime that depends on the args passed, and the last lines of the main method are this:

void main() {
  runApp(const MyApp());
  doWhenWindowReady(() {  
    if (isService) {  
      appWindow.hide();   
      //sets up the service and stuff...
    } else {   
      //sets the windows properties...
      appWindow.show();
    }  
  });  
}

I continued developing the app without worries, because in Android Studio everything worked fine: when it was supposed to show the GUI, it showed the GUI, and when it was started as a service, there was no thing on the screen ever.

The problem appeared when I started preparing to deploy it: I noticed that the hide() method seemed to be ignored because when I started it as a service, I got a total black GUI with nothing on it (and that was right, since the only widget is an empty container when it's a service). Everything else worked as intended, though.

I narrowed down the variables (used the same PC, changed some lines of code to be sure, etc), and now I am at this point: the app's code is a copy-paste of the example, except for this part:

doWhenWindowReady(() {
    if (true) { 
      appWindow.hide(); 
      return;
    }
    final win = appWindow;
    const initialSize = Size(600, 450);
    win.minSize = initialSize;
    win.size = initialSize;
    win.alignment = Alignment.center;
    win.title = "Custom window with Flutter";
    win.show();
  });

In Android Studio, it works as intended: nothing is shown until I uncomment the hide() and return lines. But, if I build the app with the code shown above and then run it, I still get the example's orange window, but with a size different from 600x450, meaning that the return gets executed but not the hide(). Any hints on why the hide() command is working differently?

Plugin version: 0.1.5 Flutter doctor:

[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Versione 10.0.19045.3086], locale it-IT) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.0) [√] Android Studio (version 2022.2)

boganiLuca avatar Jun 20 '23 14:06 boganiLuca

Same here, does this lib no longer matained?

luohao123 avatar Sep 20 '23 15:09 luohao123