Skip to content

Commit 08e5ce7

Browse files
committed
Update README.md
1 parent 46caa38 commit 08e5ce7

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

README-ZH.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- [API](#api)
3636
- [WindowManager](#windowmanager)
3737
- [Methods](#methods)
38+
- [destroy `macos` `windows`](#destroy--macos--windows)
3839
- [close](#close)
3940
- [isPreventClose](#ispreventclose)
4041
- [setPreventClose](#setpreventclose)
@@ -285,21 +286,22 @@ class _HomePageState extends State<HomePage> with WindowListener {
285286
@override
286287
void initState() {
287288
windowManager.addListener(this);
289+
_init();
288290
super.initState();
289291
}
290292
291-
void _init() async {
292-
// 添加此行以覆盖默认关闭处理程序
293-
await windowManager.setPreventClose(true);
294-
setState(() {});
295-
}
296-
297293
@override
298294
void dispose() {
299295
windowManager.removeListener(this);
300296
super.dispose();
301297
}
302298
299+
void _init() async {
300+
// 添加此行以覆盖默认关闭处理程序
301+
await windowManager.setPreventClose(true);
302+
setState(() {});
303+
}
304+
303305
@override
304306
Widget build(BuildContext context) {
305307
// ...
@@ -325,7 +327,7 @@ class _HomePageState extends State<HomePage> with WindowListener {
325327
child: Text('Yes'),
326328
onPressed: () {
327329
Navigator.of(context).pop();
328-
exit(0);
330+
await windowManager.destroy();
329331
},
330332
),
331333
],
@@ -441,6 +443,11 @@ class _HomePageState extends State<HomePage> with WindowListener {
441443

442444
#### Methods
443445

446+
##### destroy `macos` `windows`
447+
448+
Force closing the window.
449+
450+
444451
##### close
445452

446453
Try to close the window.

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,21 +286,22 @@ class _HomePageState extends State<HomePage> with WindowListener {
286286
@override
287287
void initState() {
288288
windowManager.addListener(this);
289+
_init();
289290
super.initState();
290291
}
291292
292-
void _init() async {
293-
// Add this line to override the default close handler
294-
await windowManager.setPreventClose(true);
295-
setState(() {});
296-
}
297-
298293
@override
299294
void dispose() {
300295
windowManager.removeListener(this);
301296
super.dispose();
302297
}
303298
299+
void _init() async {
300+
// Add this line to override the default close handler
301+
await windowManager.setPreventClose(true);
302+
setState(() {});
303+
}
304+
304305
@override
305306
Widget build(BuildContext context) {
306307
// ...
@@ -326,7 +327,7 @@ class _HomePageState extends State<HomePage> with WindowListener {
326327
child: Text('Yes'),
327328
onPressed: () {
328329
Navigator.of(context).pop();
329-
exit(0);
330+
await windowManager.destroy();
330331
},
331332
),
332333
],

0 commit comments

Comments
 (0)