Search code examples
performanceflutterdartmemory-efficient

Is it better to use a JSON configuration file that loads at the beginning of App or using classes that has static/final variables in Flutter?


I'm creating an app using Flutter that has around 1500+ predefined colors and gradients. I was wondering should I create a configuration file that always loads at the beginning of the app or should I create a class that has static final/const variables such as map+list?

Which one would be more memory efficient, less error prone and code friendly? Any suggestions?

Thanks a lot!


Solution

  • Thanks for all the comments. Now since I don’t need to do update OTA, I decided to create a class with static map+list combination

    I found the benefits are: 1. Less error prone because the naming will be checked by editor. 2. Only loaded in pages where we need it. 3. Compared to reading from a JSON files, it doesn’t need async functions to get the data thus faster. Because File reading is an I/O operation