Skip to content

Commit

Permalink
Merge pull request #8 from 15563988825/cadd_heckforupdates_withoutui
Browse files Browse the repository at this point in the history
Windows平台新增函数
  • Loading branch information
lijy91 authored Mar 31, 2022
2 parents d4e1587 + 26de6bb commit 028c2b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
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();
}

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

0 comments on commit 028c2b6

Please sign in to comment.