Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows平台新增函数 #8

Merged
merged 5 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions example/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class _HomePageState extends State<HomePage> {
await autoUpdater.checkForUpdates();
}

void _handleClickCheckForUpdatesWithoutUI() async {
await autoUpdater.checkForUpdatesWithoutUI();
}

Widget _buildBody(BuildContext context) {
return PreferenceList(
children: <Widget>[
Expand All @@ -44,6 +48,12 @@ class _HomePageState extends State<HomePage> {
_handleClickCheckForUpdates();
},
),
PreferenceListItem(
title: const Text('checkForUpdatesWithoutUI'),
onTap: () {
_handleClickCheckForUpdatesWithoutUI();
},
),
],
),
],
Expand Down
3 changes: 3 additions & 0 deletions lib/src/auto_updater.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class AutoUpdater {
Future<void> checkForUpdates() async {
await _channel.invokeMethod('checkForUpdates');
}
Future<void> checkForUpdatesWithoutUI() async {
await _channel.invokeMethod('checkForUpdatesWithoutUI');
}
}

final autoUpdater = AutoUpdater.instance;
5 changes: 5 additions & 0 deletions windows/auto_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class AutoUpdater {

void AutoUpdater::SetFeedURL(std::string feedURL);
void AutoUpdater::CheckForUpdates();
void AutoUpdater::CheckForUpdatesWithoutUI();

private:
};
Expand All @@ -28,4 +29,8 @@ void AutoUpdater::CheckForUpdates() {
win_sparkle_check_update_with_ui();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里修改了不应该修改的代码,请将代码按照代码风格(.clang-format)进行格式化


void AutoUpdater::CheckForUpdatesWithoutUI() {
win_sparkle_check_update_without_ui();
}

} // namespace
5 changes: 4 additions & 1 deletion windows/auto_updater_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ void AutoUpdaterPlugin::HandleMethodCall(
} else if (method_name.compare("checkForUpdates") == 0) {
auto_updater->CheckForUpdates();
result->Success(flutter::EncodableValue(true));
} else {
} else if(method_name.compare("checkForUpdatesWithoutUI") == 0){
auto_updater->CheckForUpdatesWithoutUI();
result->Success(flutter::EncodableValue(true));
}else {
result->NotImplemented();
}
}
Expand Down