Home > Back-end >  How to create a global value in flutter
How to create a global value in flutter

Time:09-24

I have a value store in Firebase config . When my app starts I would like to read the value and have it accessible from anywhere in my app.

I cannot use provider because I may not have the context. How can I do this in Flutter

Thanks

CodePudding user response:

You can either store it in one dart file or in a class with variable with static field and whenever you need it you can grab it and read or change from there.

If it needs to stay even after you restart the app, you should use https://pub.dev/packages/shared_preferences package

  • Related