karjan
karjan

Reputation: 1016

Flutter upgrader, prompt showing only once

I try to force users to upgrade app each time there is a new version with https://pub.dev/packages/upgrader. It works but only once, when there is a new version. When the dialog is opened and the user closes app. It won't ask again for update. Anyone has solution to that?

Upvotes: 3

Views: 2788

Answers (2)

milano zz
milano zz

Reputation: 116

the default value for upgrader to remind user to update app is 3 days if you want to change this time you can use durationUntilAlertAgain parameter

upgrader: Upgrader(                      
          durationUntilAlertAgain: const Duration(minutes: 5),
        ),

for exmaple: durationUntilAlertAgain: const Duration(minutes: 5),

in the above example if the user close app at 00:00 am and re-open it at 00:03 am the alert message will not appear however if user re-open it at 00:07 am or later the alert message will appear

alternatively you can force user to update the app by adding exit function to ignore or later button here is an example solve your question :

 UpgradeAlert(
        upgrader: Upgrader(             
          showLater: false,          
          onIgnore: () {
            SystemNavigator.pop();
             throw UnsupportedError('_');
          },
        ),
        child: HomePage(),
      ),

Upvotes: 7

kamran khan
kamran khan

Reputation: 11

How frequent do you want dialog to pop up? Upgrader widget accepts an attribute durationUntilAlertAgain and its accpetion object of Duration(). You pass whatever duration you want dialog will pop up after that duration.

Upvotes: 1

Related Questions