leanflutter / window_manager

This plugin allows Flutter desktop apps to resizing and repositioning the window.
https://pub.dev/packages/window_manager
MIT License
725 stars 205 forks source link

Window flashes when startup since version 0.3.7 on Windows #504

Open chenghang6 opened 1 month ago

chenghang6 commented 1 month ago

Window flashes when startup since version 0.3.7 on Windows. WindowOptions is set with "center: true" and "titleBarStyle: TitleBarStyle.hidden". It seems that the window is initially located somewhere else, then moved to the center.

import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
import 'package:screen_retriever/screen_retriever.dart';
import 'dart:io';

const windowWidthRatio = 0.65;
const windowHeightRatio = 0.75;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await windowManager.ensureInitialized();

  var primaryDisplay = await screenRetriever.getPrimaryDisplay();

  runApp(Material(child: Container()));

  var screenSize = primaryDisplay.size;
  double windowWidth = screenSize.width * windowWidthRatio;
  double windowHeight = screenSize.height * windowHeightRatio;

  WindowOptions windowOptions = WindowOptions(
    size: Size(windowWidth, windowHeight),
    center: true,
    titleBarStyle: TitleBarStyle.hidden,
  );

  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.show();
    await windowManager.focus();
  });
}
  window_manager: ^0.4.0
chenghang6 commented 1 month ago

After testing, I am pretty sure it's introduced by commit: 609df9d7d3d80d456d0b83ef31b1d85f9f62befe

tonka3000 commented 3 weeks ago

I have the same issue, but only in Debug mode. Release mode seems not to be affected. I use 0.4.2. Also tried 0.4.3, still the same issue.