Search code examples
flutterdartglobal-variables

Handling variables across the flutter app


I am refactoring an old app I wrote a few years ago. In the original app I used global variables to access different data across the app such as permissions and IDs.

I know globals are not the best way of providing access to data across the app so I am asking what is the best way. Is it service classes or something else?

Thanks


Solution

  • You can use libraries such as "provider" or "get" and handle the variables in their classes, it's the best way to save the variables

    These are the libraries:

    provider: https://pub.dev/packages/provider

    get: https://pub.dev/packages/get

    there is another libraries such as block, etc...