Skip to content

Commit e315bda

Browse files
committed
chore(example): Update example for close app
1 parent ef26b7f commit e315bda

File tree

5 files changed

+67
-56
lines changed

5 files changed

+67
-56
lines changed

README-ZH.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
这个插件允许 Flutter **桌面** 应用自动更新自己 (基于 [sparkle](https://sparkle-project.org/)[winsparkle](https://winsparkle.com))。
1111

12-
<img src="screenshots/sparkle.png" width="732" alt="">
12+
<img src="https://raw.githubusercontent.com/leanflutter/auto_updater/main/screenshots/sparkle.png" width="732" alt="">
1313

1414
---
1515

@@ -20,33 +20,34 @@
2020
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2121
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
2222

23-
- [平台支持](#%E5%B9%B3%E5%8F%B0%E6%94%AF%E6%8C%81)
24-
- [快速开始](#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)
25-
- [安装](#%E5%AE%89%E8%A3%85)
26-
- [⚠️ Windows requirements](#-windows-requirements)
27-
- [用法](#%E7%94%A8%E6%B3%95)
28-
- [发布你的应用](#%E5%8F%91%E5%B8%83%E4%BD%A0%E7%9A%84%E5%BA%94%E7%94%A8)
29-
- [生成私钥](#%E7%94%9F%E6%88%90%E7%A7%81%E9%92%A5)
30-
- [macOS](#macos)
31-
- [Windows](#windows)
32-
- [打包应用](#%E6%89%93%E5%8C%85%E5%BA%94%E7%94%A8)
33-
- [macOS](#macos-1)
34-
- [Windows](#windows-1)
35-
- [获取签名](#%E8%8E%B7%E5%8F%96%E7%AD%BE%E5%90%8D)
36-
- [macOS](#macos-2)
37-
- [Windows](#windows-2)
38-
- [分发应用](#%E5%88%86%E5%8F%91%E5%BA%94%E7%94%A8)
39-
- [故障排除](#%E6%95%85%E9%9A%9C%E6%8E%92%E9%99%A4)
40-
- [macOS](#macos-3)
41-
- [谁在用使用它?](#%E8%B0%81%E5%9C%A8%E7%94%A8%E4%BD%BF%E7%94%A8%E5%AE%83)
42-
- [API](#api)
43-
- [AutoUpdater](#autoupdater)
44-
- [Methods](#methods)
45-
- [setFeedURL](#setfeedurl)
46-
- [checkForUpdates](#checkforupdates)
47-
- [setScheduledCheckInterval](#setscheduledcheckinterval)
48-
- [相关链接](#%E7%9B%B8%E5%85%B3%E9%93%BE%E6%8E%A5)
49-
- [许可证](#%E8%AE%B8%E5%8F%AF%E8%AF%81)
23+
- [auto\_updater](#auto_updater)
24+
- [平台支持](#平台支持)
25+
- [快速开始](#快速开始)
26+
- [安装](#安装)
27+
- [⚠️ Windows requirements](#️-windows-requirements)
28+
- [用法](#用法)
29+
- [发布你的应用](#发布你的应用)
30+
- [生成私钥](#生成私钥)
31+
- [macOS](#macos)
32+
- [Windows](#windows)
33+
- [打包应用](#打包应用)
34+
- [macOS](#macos-1)
35+
- [Windows](#windows-1)
36+
- [获取签名](#获取签名)
37+
- [macOS](#macos-2)
38+
- [Windows](#windows-2)
39+
- [分发应用](#分发应用)
40+
- [故障排除](#故障排除)
41+
- [macOS](#macos-3)
42+
- [谁在用使用它?](#谁在用使用它)
43+
- [API](#api)
44+
- [AutoUpdater](#autoupdater)
45+
- [Methods](#methods)
46+
- [setFeedURL](#setfeedurl)
47+
- [checkForUpdates](#checkforupdates)
48+
- [setScheduledCheckInterval](#setscheduledcheckinterval)
49+
- [相关链接](#相关链接)
50+
- [许可证](#许可证)
5051

5152
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
5253

README.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
This plugin allows Flutter **desktop** apps to automatically update themselves (based on [sparkle](https://sparkle-project.org/) and [winsparkle](https://winsparkle.com)).
1111

12-
<img src="screenshots/sparkle.png" width="732" alt="">
12+
<img src="https://raw.githubusercontent.com/leanflutter/auto_updater/main/screenshots/sparkle.png" width="732" alt="">
1313

1414
---
1515

@@ -20,33 +20,34 @@ English | [简体中文](./README-ZH.md)
2020
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2121
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
2222

23-
- [Platform Support](#platform-support)
24-
- [Quick Start](#quick-start)
25-
- [Installation](#installation)
26-
- [⚠️ Windows requirements](#-windows-requirements)
27-
- [Usage](#usage)
28-
- [Publish your app](#publish-your-app)
29-
- [Generate private key](#generate-private-key)
30-
- [macOS](#macos)
31-
- [Windows](#windows)
32-
- [Packaging](#packaging)
33-
- [macOS](#macos-1)
34-
- [Windows](#windows-1)
35-
- [Get signature](#get-signature)
36-
- [macOS](#macos-2)
37-
- [Windows](#windows-2)
38-
- [Distributing](#distributing)
39-
- [Troubleshooting](#troubleshooting)
40-
- [macOS](#macos-3)
41-
- [Who's using it?](#whos-using-it)
42-
- [API](#api)
43-
- [AutoUpdater](#autoupdater)
44-
- [Methods](#methods)
45-
- [setFeedURL](#setfeedurl)
46-
- [checkForUpdates](#checkforupdates)
47-
- [setScheduledCheckInterval](#setscheduledcheckinterval)
48-
- [Related Links](#related-links)
49-
- [License](#license)
23+
- [auto\_updater](#auto_updater)
24+
- [Platform Support](#platform-support)
25+
- [Quick Start](#quick-start)
26+
- [Installation](#installation)
27+
- [⚠️ Windows requirements](#️-windows-requirements)
28+
- [Usage](#usage)
29+
- [Publish your app](#publish-your-app)
30+
- [Generate private key](#generate-private-key)
31+
- [macOS](#macos)
32+
- [Windows](#windows)
33+
- [Packaging](#packaging)
34+
- [macOS](#macos-1)
35+
- [Windows](#windows-1)
36+
- [Get signature](#get-signature)
37+
- [macOS](#macos-2)
38+
- [Windows](#windows-2)
39+
- [Distributing](#distributing)
40+
- [Troubleshooting](#troubleshooting)
41+
- [macOS](#macos-3)
42+
- [Who's using it?](#whos-using-it)
43+
- [API](#api)
44+
- [AutoUpdater](#autoupdater)
45+
- [Methods](#methods)
46+
- [setFeedURL](#setfeedurl)
47+
- [checkForUpdates](#checkforupdates)
48+
- [setScheduledCheckInterval](#setscheduledcheckinterval)
49+
- [Related Links](#related-links)
50+
- [License](#license)
5051

5152
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
5253

packages/auto_updater/example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ void main() async {
88
await windowManager.ensureInitialized();
99

1010
windowManager.waitUntilReadyToShow(null, () async {
11+
await windowManager.setPreventClose(true);
1112
await windowManager.show();
1213
await windowManager.focus();
1314
});

packages/auto_updater/example/lib/pages/home.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:bot_toast/bot_toast.dart';
33
import 'package:flutter/foundation.dart';
44
import 'package:flutter/material.dart';
55
import 'package:preference_list/preference_list.dart';
6+
import 'package:window_manager/window_manager.dart';
67

78
class HomePage extends StatefulWidget {
89
const HomePage({super.key});
@@ -136,5 +137,6 @@ class _HomePageState extends State<HomePage> with UpdaterListener {
136137
if (kDebugMode) {
137138
print('onUpdaterBeforeQuitForUpdate: ${item?.toJson()}');
138139
}
140+
windowManager.setPreventClose(false);
139141
}
140142
}

packages/auto_updater/example/windows/runner/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
99
_In_ wchar_t *command_line, _In_ int show_command) {
10+
HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"auto_updater_example");
11+
if (hwnd != NULL) {
12+
::ShowWindow(hwnd, SW_NORMAL);
13+
::SetForegroundWindow(hwnd);
14+
return EXIT_FAILURE;
15+
}
1016
// Attach to console when present (e.g., 'flutter run') or create a
1117
// new console when running with a debugger.
1218
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {

0 commit comments

Comments
 (0)