'Upgrade Alert is showing continuously after I navigate to different screens in Flutter

I am using upgrader package to show alert to user if a new version of app is available on playstore. But, after using it on a screen, it is appearing multiple times throughout the app. How can I fix this?

Widget build(BuildContext context) {
    Upgrader().clearSavedSettings();
    return WillPopScope(
      onWillPop: _onWillPop,
      child: Scaffold(
        backgroundColor: backgroundColor,
        body: UpgradeAlert(
          debugLogging: true,
          child: ShowCaseWidget(


Solution 1:[1]

You should not use it in the build method because assume this: Whenever the widget is rebuilded - Upgrader().clearSavedSettings(); will be called. Utilize this functions using methods below:

  1. Call it in initState of your State. Then it will be called whenever your widget's state is created.
  2. If you want to call this method continiously - create stream with Stream.periodic inside the initState of your root widget's state.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kerim