Skip to content

[shared_preferences] Document return values of set and remove methods - #12303

Open
binSaed wants to merge 3 commits into
flutter:mainfrom
binSaed:document-set-return-values-146070
Open

[shared_preferences] Document return values of set and remove methods#12303
binSaed wants to merge 3 commits into
flutter:mainfrom
binSaed:document-set-return-values-146070

Conversation

@binSaed

@binSaed binSaed commented Jul 28, 2026

Copy link
Copy Markdown

The setBool, setInt, setDouble, setString, setStringList, and remove methods on SharedPreferences all return Future<bool>, but the documentation never explains what the return value means. As noted in a prior PR review, the return value is not self-documenting and required reading every platform implementation to understand.

This PR adds dartdoc to each of these methods using the wording suggested in that review:

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.

Fixes flutter/flutter#146070

Pre-Review Checklist

Version/CHANGELOG note: documentation-only change; added a CHANGELOG entry under the existing ## NEXT section with no version bump.
Test exemption: documentation-only change (dartdoc comments only, no code changes).

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation comments for the setBool, setInt, setDouble, setString, setStringList, and remove methods in SharedPreferences to clarify their return value behavior. Specifically, it explains that these methods return false if the platform implementation definitively determines that the operation failed, and true otherwise. There are no review comments, so there is no additional feedback to provide.

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! Because of the volume of PRs we receive, we require that new contributors use our checklist to guide them through critical steps in creating a Flutter PR. This PR's description is missing that checklist, so it is being marked as a Draft.

Please edit the PR description to add the checklist, then ensure that you have completed all of the steps. Once you've done that, please mark the PR as ready for review.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

(In the future, please don't ping people in PR descriptions. This causes pings both when the PR is opened, and also when the PR description becomes the commit message, and then many more times when people update their forks of the repository to include that commit. I've removed username references from the description.)

@binSaed
binSaed force-pushed the document-set-return-values-146070 branch from 16021cc to 47df70c Compare July 29, 2026 13:45
@binSaed binSaed changed the title Document return values of set and remove methods in SharedPreferences [shared_preferences] Document return values of set and remove methods Jul 29, 2026
@binSaed
binSaed force-pushed the document-set-return-values-146070 branch from 47df70c to 3223ba7 Compare July 29, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[shared_preferences] document return values of remove and set... methods

2 participants