Skip to content

Window flashes when startup since version 0.3.7 on Windows #504

Open
@chenghang6

Description

@chenghang6

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions