@@ -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,7 +279,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
276279
277280##### macOS
278281
279- Change the file MainFlutterWindow.swift as follows:
282+ Change the file ` macos/Runner/ MainFlutterWindow.swift` as follows:
280283
281284``` diff
282285import Cocoa
@@ -305,7 +308,7 @@ class MainFlutterWindow: NSWindow {
305308
306309##### Windows
307310
308- Change the file windows\ runner\ win32_window.cpp as follows:
311+ Change the file ` windows/ runner/ win32_window.cpp ` as follows:
309312
310313``` diff
311314bool Win32Window::CreateAndShow(const std::wstring& title,
@@ -321,6 +324,45 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
321324 nullptr, nullptr, GetModuleHandle(nullptr), this);
322325```
323326
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+
324366## Who's using it?
325367
326368- [ AuthPass] ( https://authpass.app/ ) - Password Manager based on Flutter for all platforms. Keepass 2.x (kdbx 3.x) compatible.
0 commit comments