I'm using the well known package shared_preferences
to store data. I'm running my flutter app as a MacOS desktop application, not on Android. How can I access the file to see a good overview of what is being stored? Any help will be appreciated.
Asked
Active
Viewed 462 times
1

rednaxela
- 661
- 2
- 9
- 21
3 Answers
1
Think I found the answer. In terminal write
defaults read uk.co.mytestapp

rednaxela
- 661
- 2
- 9
- 21
-
Thank you. Do you know how to write to it ? – TSR Feb 19 '23 at 18:20
0
Data may be persisted to disk asynchronously, and there is no guarantee that writes will be persisted to disk after returning, so this plugin must not be used for storing critical data.

Joarder Shawon
- 3
- 2
0
I think you can find everything you're looking for in the api library.
SharedPreferences prefs = await SharedPreferences.getInstance();
Set<String> keys = prefs.getKeys(); //this will return all the keys stored in your ios disk memory
Object? data = prefs.get(key); //this will return the data for the key you want from your ios disk memory

eyoeldefare
- 2,136
- 1
- 15
- 25
-
But is there not a location on the Mac where the json file is stored that I can view? – rednaxela Jul 05 '21 at 08:01
-
I am not using Mac so I am not sure but since Shared Preference is same as NSUserDefaults on mac and ios, you should look at where your computer stores NSUserDefaults data on disk. – eyoeldefare Jul 05 '21 at 19:19