[shared_preferences] Documentation update for Readme.md#4684
[shared_preferences] Documentation update for Readme.md#4684fluttergithubbot merged 10 commits intoflutter:mainfrom
Conversation
| 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. | ||
|
|
||
| Although key-value storage is easy and convenient to use, it has limitations: |
There was a problem hiding this comment.
Limitations relative to what? Only allowing specific types of data is not unusual, for instance.
I'm not sure this sentence adds anything, really. "easy and convenient" seems very subjective, and again I'm not sure what it's being compared to.
There was a problem hiding this comment.
Yes, may be not the best words to describe. Dropping sentence out..
| returning, so this plugin must not be used for storing critical data. | ||
|
|
||
| Although key-value storage is easy and convenient to use, it has limitations: | ||
| * Only primitive types can be used: `int`, `double`, `bool`, `String`, and `StringList`. |
There was a problem hiding this comment.
As far as I know "primitive types" is not a meaningful term in Dart. I would just list the supported types without trying to editorialize it as a limitation, or trying to use a term to describe them. (I don't think the latter is even possible I can't imagine any term that would encompas lists of strings but not lists of doubles, for instance.)
There was a problem hiding this comment.
Indeed, yes, re-phrased this.
| returning, so this plugin must not be used for storing critical data. | ||
|
|
||
| Although key-value storage is easy and convenient to use, it has limitations: | ||
| * Only primitive types can be used: `int`, `double`, `bool`, `String`, and `StringList`. |
There was a problem hiding this comment.
There is no Dart type StringList.
| Although key-value storage is easy and convenient to use, it has limitations: | ||
| * Only primitive types can be used: `int`, `double`, `bool`, `String`, and `StringList`. | ||
| * It’s not designed to store a lot of data. | ||
| * No encryption for data. |
There was a problem hiding this comment.
This is potentially misleading, since on some platforms all data is encrypted at some level. I don't think we need to discuss encryption at all.
| final success = await prefs.clear(); | ||
| ``` | ||
|
|
||
| ### Sample Usage |
There was a problem hiding this comment.
There is no real difference in meaning between "Examples" and "Sample Usage", so having both is confusing.
Since almost everything in the code below is irrelevant, and anyone wanting that kind of example has the Example tab on pub.dev, I would just remove this whole section in favor of the above.
There was a problem hiding this comment.
I would focus more on simple examples here. That's true that simple example app is accessible and easier to read via pub.dev. Thanks for feedback.
| SharedPreferences.setMockInitialValues(values); | ||
| ``` | ||
|
|
||
| ### Storage location on platforms |
There was a problem hiding this comment.
s/on platforms/by platform/
| | :--- | :--- | | ||
| | Android | SharedPreferences | | ||
| | iOS | NSUserDefaults | | ||
| | Linux | LocalFileSystem | |
There was a problem hiding this comment.
I don't think the name of the class that abstracts the filesystem in Dart is a meaningful description. Saying "In the XDG_DATA_HOME directory" would be a lot more meaningful.
| | Linux | LocalFileSystem | | ||
| | MacOS | NSUserDefaults | | ||
| | Web | LocalStorage | | ||
| | Windows | LocalFileSystem | |
There was a problem hiding this comment.
As with Linux: "In the roaming AppData directory"
stuartmorgan-g
left a comment
There was a problem hiding this comment.
@bparrishMines for secondary review.
|
|
||
| #### Remove an entry | ||
| ```dart | ||
| // Remove data from the provided key. |
There was a problem hiding this comment.
s/from/for/
Also, in all the comments above you used the name of the key rather than saying "the provided key", and this should be consistent.
|
|
||
| #### Read data | ||
| ```dart | ||
| final SharedPreferences prefs = await _prefs; |
There was a problem hiding this comment.
I don't know what _prefs is supposed to be here. Why is the code for getting the shared preferences different in this example from the example above?
| | Web | LocalStorage | | ||
| | Windows | In the roaming AppData directory | | ||
|
|
||
| [example]:./example No newline at end of file |
There was a problem hiding this comment.
This seems to be dead code.
Update for documentation on readme file:
Fixes flutter/flutter#96993
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.