[shared_preferences] Documented return values for remove and set methods. - #7198
[shared_preferences] Documented return values for remove and set methods.#7198RamonFarizel wants to merge 11 commits into
Conversation
|
All of the changelogs and pubspecs changes for the sub packages (android, foundation, etc) should be reverted. Only the subpackages with changes need them. |
|
I'm of the opinion that these changes to the doc comments aren't necessary, as the methods are self documenting. You can't call The "returns true" comments are unfortunately not exactly correct, as some platforms don't actually have any response that verifies success. If I were to design this api myself today, I wouldn't have any bool returns for that reason. @stuartmorgan what do you think? |
I don't think the return value is self-documenting; I literally had to go back and read every platform's implementation to figure out what it actually does, and I wrote several of those implementations. I think it's worth trying to describe the reality of what they do as best we can, which I agree the proposed language doesn't do because of the differences across platforms. The best we can do is probably something like: /// Returns `false` if the platform implementation can definitively determine that storing the preference
/// failed. A return value of `true` indicates either that the value was written successfully, or that the
/// underlying platform API does not report success or failure.
Yes, those parts of the additions are not correct; the cases described would not compile, so could not throw at runtime. |
|
Thanks for your thoughts, folks. So if we are moving with updating the docs, what do you think is the best approach?
|
|
Unless something is part of the comment directly on a method, it won't show up in IDE tools, and it will be harder to find even when looking at the header manually, so far fewer people would see anything added anywhere but to each method. |
|
Okay, I've implemented the changes. |
Add dartdoc to setBool, setInt, setDouble, setString, setStringList, and remove explaining the meaning of their return values, using the wording suggested by @stuartmorgan-g in the closed PR flutter#7198. Fixes flutter/flutter#146070
This PR adds documentation about the
removeandsetmethods.Those methods are basically following the
getmethods patterns, they throw an exception when the type is not expected.Also, returns true when the operation succeeded.
List which issues are fixed by this PR. You must list at least one issue.
fixes: #146070
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, or this PR is exempt from CHANGELOG changes.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.