diff --git a/example/lib/pages/home.dart b/example/lib/pages/home.dart index 6436146..0588073 100644 --- a/example/lib/pages/home.dart +++ b/example/lib/pages/home.dart @@ -25,6 +25,10 @@ class _HomePageState extends State { await autoUpdater.checkForUpdates(); } + void _handleClickCheckForUpdatesWithoutUI() async { + await autoUpdater.checkForUpdatesWithoutUI(); + } + Widget _buildBody(BuildContext context) { return PreferenceList( children: [ @@ -44,6 +48,12 @@ class _HomePageState extends State { _handleClickCheckForUpdates(); }, ), + PreferenceListItem( + title: const Text('checkForUpdatesWithoutUI'), + onTap: () { + _handleClickCheckForUpdatesWithoutUI(); + }, + ), ], ), ], diff --git a/lib/src/auto_updater.dart b/lib/src/auto_updater.dart index 126ae2a..4868379 100644 --- a/lib/src/auto_updater.dart +++ b/lib/src/auto_updater.dart @@ -29,6 +29,9 @@ class AutoUpdater { Future checkForUpdates() async { await _channel.invokeMethod('checkForUpdates'); } + Future checkForUpdatesWithoutUI() async { + await _channel.invokeMethod('checkForUpdatesWithoutUI'); + } } final autoUpdater = AutoUpdater.instance; diff --git a/windows/auto_updater.cpp b/windows/auto_updater.cpp index 6731864..f7bf9ca 100644 --- a/windows/auto_updater.cpp +++ b/windows/auto_updater.cpp @@ -11,6 +11,7 @@ class AutoUpdater { void AutoUpdater::SetFeedURL(std::string feedURL); void AutoUpdater::CheckForUpdates(); + void AutoUpdater::CheckForUpdatesWithoutUI(); private: }; @@ -28,4 +29,8 @@ void AutoUpdater::CheckForUpdates() { win_sparkle_check_update_with_ui(); } +void AutoUpdater::CheckForUpdatesWithoutUI() { + win_sparkle_check_update_without_ui(); +} + } // namespace diff --git a/windows/auto_updater_plugin.cpp b/windows/auto_updater_plugin.cpp index 764e76c..9d2684d 100644 --- a/windows/auto_updater_plugin.cpp +++ b/windows/auto_updater_plugin.cpp @@ -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(); } }