'Flutter : What is the maximum weight of global variables?
Good morning all,
I'm looking to know how variables are stored in a flutter application. I don't really know the world of mobile, so I'm a little lost. I'm on a project in which I have to store information when launching the application, which I retrieve via an API (they are then deleted when the user closes the application). Currently, the amount of data is reasonable, but I would like to know how much data I can temporarily store in my application (10kb? 10mo?), what are the risks with this way of doing things, does it have slow down the app...
I couldn't find anything on the flutter doc (https://docs.flutter.dev/perf/memory - At the time of writing this message, the line returns to an empty page with the letters TBD). I couldn't find any articles explaining the specifics of memory, performance related variable storage, related to flutter.
Thanks for your help !
Solution 1:[1]
The Dart compiler used by Flutter is actually very good at optimizing code, so variables have almost zero overhead.
Having said that I must add that using global variables is not a good way of storing data in any kind of software. I suppose you select a suitable state management technique to handle your data.
Regarding the amount of data, I don't think 10mo will be too much on a modern mobile device, but as always, ymmv.
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 | Ber |
