bitsdojo / bitsdojo_window

A Flutter package that makes it easy to customize and work with your Flutter desktop app window.
http://www.youtube.com/watch?v=bee2AHQpGK4
MIT License
815 stars 229 forks source link

white screen does not display #176

Open au-top opened 2 years ago

au-top commented 2 years ago

When I start on windows, there may be a white screen. I need to resize the window size (I suspect it is forced to let the fluent engine refresh the screen) before it can be displayed


bitsdojo_window:
    dependency: "direct main"
    description:
      name: bitsdojo_window
      url: "https://pub.flutter-io.cn"
    source: hosted
    version: "0.1.2"
  bitsdojo_window_linux:
    dependency: transitive
    description:
      name: bitsdojo_window_linux
      url: "https://pub.flutter-io.cn"
    source: hosted
    version: "0.1.2"
  bitsdojo_window_macos:
    dependency: transitive
    description:
      name: bitsdojo_window_macos
      url: "https://pub.flutter-io.cn"
    source: hosted
    version: "0.1.2"
  bitsdojo_window_platform_interface:
    dependency: transitive
    description:
      name: bitsdojo_window_platform_interface
      url: "https://pub.flutter-io.cn"
    source: hosted
    version: "0.1.2"
  bitsdojo_window_windows:
    dependency: transitive
    description:
      name: bitsdojo_window_windows
      url: "https://pub.flutter-io.cn"
    source: hosted
    version: "0.1.2"

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
[√] Flutter (Channel master, 3.1.0-0.0.pre.854, on Microsoft Windows [版本 10.0.22000.675], locale zh-CN)
    • Flutter version 3.1.0-0.0.pre.854 at D:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ec20ea80ad (2 days ago), 2022-05-21 16:28:06 -0400
    • Engine revision 1bfe551d6b
    • Dart version 2.18.0 (build 2.18.0-142.0.dev)
    • DevTools version 2.13.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at D:\AndroidSDK
    • Platform android-32, build-tools 32.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.6)
    • Visual Studio at D:\VSSDK\IDE
    • Visual Studio Community 2022 version 17.1.32421.90
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] IntelliJ IDEA Ultimate Edition (version 2021.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] VS Code (version 1.67.2)
    • VS Code at C:\Users\autop\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.41.20220516

[√] VS Code (version 1.68.0-insider)
    • VS Code at C:\Users\autop\AppData\Local\Programs\Microsoft VS Code Insiders
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[!] Proxy Configuration
    • HTTP_PROXY is set
    • NO_PROXY is localhost,127.0.0.1
    • NO_PROXY contains localhost
    ! NO_PROXY does not contain ::1
    • NO_PROXY contains 127.0.0.1

[√] Connected device (5 available)
    • DBY W09 (mobile)  • DXQBB21C02222514   • android-arm64  • Android 10 (API 29)
    • DBY W09 (mobile)  • 192.168.2.101:5555 • android-arm64  • Android 10 (API 29)
    • Windows (desktop) • windows            • windows-x64    • Microsoft Windows [版本 10.0.22000.675]
    • Chrome (web)      • chrome             • web-javascript • Google Chrome 101.0.4951.67
    • Edge (web)        • edge               • web-javascript • Microsoft Edge 100.0.1185.29

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
ProfessorAO commented 1 year ago

Hi I have the same problem, did you manage to fix this?

xioxin commented 1 year ago

Use setWindowVisibility(visible: true); of the window_size package to display the window.

This package is not published to pub.dev, so you need to add it via git.

https://github.com/google/flutter-desktop-embedding/tree/main/plugins/window_size

# pubspec.yaml
dependencies:
  window_size:
    git:
      url: https://github.com/google/flutter-desktop-embedding.git
      path: plugins/window_size
void main() {
  runApp(MyApp());
  doWhenWindowReady(() {
      setWindowVisibility(visible: true);
      setWindowTitle('My Demo');
  });
}

I'm not sure of the difference, in my case it works.

ashutosh2014 commented 1 year ago

I have fix this using https://github.com/MixinNetwork/flutter-app/pull/838

martinmarth commented 1 year ago

I have the same Problem. For me it only happens in the Release-Version of the app.
I tried implementing @xioxin's answer, but this did not help.
Since manually resizing the window also fixes the whitescreen for me, I tried to implement a workaround by setting the appWindow.size twice. e.g:

appWindow.size = const Size(1092, 800);
sleep(const Duration(milliseconds: 500));
appWindow.size = const Size(1092, 800);

But unfortunately this also did not help.

Did someone manage to fix this problem?

HEBOS commented 4 months ago

I fixed it based on @ashutosh2014 suggestion. Here is my code:

doWhenWindowReady(() {
      final win = appWindow;
      const initialSize = Size(1280, 720);
      win.minSize = initialSize;
      win.size = initialSize;
      win.alignment = Alignment.center;
      win.title = "XXX";
      WidgetsBinding.instance.scheduleFrameCallback((timeStamp) {
        appWindow.size = initialSize + const Offset(0, 1);
      });
      win.show();
    });