Search code examples
flutterstore

Is there a way to manage a global store in flutter?


In an app we may want to display some pages depend on some conditions like is authenticated or not. So managing a store is better in my view. Is there a way to manage a global store in flutter?


Solution

  • You can create a static class having all parameters eg.

    class AppConstants {
      static String dbName="Documents/APPDBv1.1.db";
      static String userid="[USER_ID]";
      static String token="[TOKEN]";
      static bool authenticated=false;
      static String syncDate="01/01/2019 00:00";
    
      static final List<String> myValue= ["A","B","C","D"];
    
    }
    

    the specific parameters can be saved to database/shared preference/local storage and can be retrieved from database/shared preference/local storage and stored in this static class.