I have a backend server with graphql. And on flutter startup, I call query to backend for initial data. This initial data needs in every screen. So how can I save and use this data in my app? I am using graphql_flutter. So first option will be calling readQuery from cached result in memory using graphql_flutter. second option will be using flutter_secure_storage. But this option is overkill for this case. Can you recommend better option for this?
Asked
Active
Viewed 637 times
0
-
1Another possible solution is to use the Shared Preferences https://pub.dev/packages/shared_preferences, if your data can be stored as key:value pairs, perhaps you could consider this package. – Rohan Thacker Apr 29 '20 at 01:46
-
1You can initialize your data holding classes as a singleton in the root of your app. Then you can cache your data objects in this singleton. With something like Provider, or InheritedWidget you can access this singleton from all over your app. – 最白目 Apr 29 '20 at 13:53