larryaasen / upgrader

A Flutter package for prompting users to upgrade when there is a newer version of the app in the store.
MIT License
567 stars 273 forks source link

Can we check for new version outside of the widget tree ? #144

Closed SogoGolf closed 2 years ago

SogoGolf commented 2 years ago

We need to be able to check for a new version from our controllers/blocs etc., and then if needed, display the update popup.

Is it possible to do this with upgrader ?

Mattjevaas commented 2 years ago

Yes it is possible, i used something like this on my project


//-- MyController.dart

//-- This code is inside async function with BuildContext as param
Upgrader upgrader = Upgrader();
await upgrader.initialize();

//-- Check if update available
if (upgrader.isUpdateAvailable()) {

 //-- Some Dialog Configuration
  upgrader.showIgnore = false;
  upgrader.messages = MyUpgraderMessages();
  upgrader.onLater = () {
      exit(0);
  };

  // -- Show Update Dialog
  upgrader.checkVersion(context: context);
}
SogoGolf commented 2 years ago

brilliant! many thanks