@@ -30,6 +30,7 @@ English | [简体中文](./README-ZH.md)
3030 - [ Windows] ( #windows )
3131 - [ Hidden at launch] ( #hidden-at-launch )
3232 - [ macOS] ( #macos-1 )
33+ - [ Windows] ( #windows-1 )
3334 - [ Who's using it?] ( #whos-using-it )
3435 - [ API] ( #api )
3536 - [ WindowManager] ( #windowmanager )
@@ -104,7 +105,7 @@ English | [简体中文](./README-ZH.md)
104105
105106### Installation
106107
107- Add this to your package's pubspec.yaml file:
108+ Add this to your package's ` pubspec.yaml ` file:
108109
109110``` yaml
110111dependencies :
@@ -134,11 +135,12 @@ void main() async {
134135
135136 // Use it only after calling `hiddenWindowAtLaunch`
136137 windowManager.waitUntilReadyToShow().then((_) async{
137- // Set to frameless window
138- await windowManager.setAsFrameless( );
139- await windowManager.setSize(Size(600 , 600));
138+ // Hide window title bar
139+ await windowManager.setTitleBarStyle('hidden' );
140+ await windowManager.setSize(Size(800 , 600));
140141 await windowManager.setPosition(Offset.zero);
141- windowManager.show();
142+ await windowManager.show();
143+ await windowManager.setSkipTaskbar(false);
142144 });
143145
144146 runApp(MyApp());
@@ -233,13 +235,14 @@ class _HomePageState extends State<HomePage> with WindowListener {
233235 }
234236}
235237```
238+
236239#### Quit on close
237240
238241If you need to use the hide method, you need to disable ` QuitOnClose ` .
239242
240243##### macOS
241244
242- ` macos/Runner/AppDelegate.swift `
245+ Change the file ` macos/Runner/AppDelegate.swift ` as follows:
243246
244247``` diff
245248import Cocoa
@@ -256,7 +259,7 @@ class AppDelegate: FlutterAppDelegate {
256259
257260##### Windows
258261
259- ` windows/runner/main.cpp `
262+ Change the file ` windows/runner/main.cpp ` as follows:
260263
261264``` diff
262265int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
@@ -276,6 +279,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
276279
277280##### macOS
278281
282+ Change the file ` macos/Runner/MainFlutterWindow.swift ` as follows:
283+
279284``` diff
280285import Cocoa
281286import FlutterMacOS
@@ -301,6 +306,63 @@ class MainFlutterWindow: NSWindow {
301306
302307```
303308
309+ ##### Windows
310+
311+ Change the file ` windows/runner/win32_window.cpp ` as follows:
312+
313+ ``` diff
314+ bool Win32Window::CreateAndShow(const std::wstring& title,
315+ const Point& origin,
316+ const Size& size) {
317+ ...
318+ HWND window = CreateWindow(
319+ - window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
320+ + window_class, title.c_str(),
321+ + WS_OVERLAPPEDWINDOW, // do not add WS_VISIBLE since the window will be shown later
322+ Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
323+ Scale(size.width, scale_factor), Scale(size.height, scale_factor),
324+ nullptr, nullptr, GetModuleHandle(nullptr), this);
325+ ```
326+
327+ Make sure to call ` setState ` once on the ` onWindowFocus ` event.
328+
329+ ``` dart
330+ import 'package:flutter/cupertino.dart';
331+ import 'package:window_manager/window_manager.dart';
332+
333+ class HomePage extends StatefulWidget {
334+ @override
335+ _HomePageState createState() => _HomePageState();
336+ }
337+
338+ class _HomePageState extends State<HomePage> with WindowListener {
339+ @override
340+ void initState() {
341+ windowManager.addListener(this);
342+ super.initState();
343+ }
344+
345+ @override
346+ void dispose() {
347+ windowManager.removeListener(this);
348+ super.dispose();
349+ }
350+
351+ @override
352+ Widget build(BuildContext context) {
353+ // ...
354+ }
355+
356+ @override
357+ void onWindowFocus() {
358+ // Make sure to call once.
359+ setState(() {});
360+ // do something
361+ }
362+ }
363+
364+ ```
365+
304366## Who's using it?
305367
306368- [ AuthPass] ( https://authpass.app/ ) - Password Manager based on Flutter for all platforms. Keepass 2.x (kdbx 3.x) compatible.
0 commit comments