Skip to content

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

Merged
auto-submit[bot] merged 8 commits into
flutter:mainfrom
binSaed:document-set-return-values-146070
Oct 5, 2026
Merged

auto-submit[bot] merged 8 commits into
flutter:mainfrom
binSaed:document-set-return-values-146070

Conversation

@binSaed

@binSaed binSaed commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

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
@@ -1,6 +1,7 @@
## NEXT

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.

The version will need to be updated to actually publish these comments. change this to 2.5.6, and update the pubspec version as well. Then it can land

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, bumped to 2.5.6 in both CHANGELOG.md and pubspec.yaml.

@binSaed
binSaed force-pushed the document-set-return-values-146070 branch from bc7c15f to 3c5f87d Compare October 3, 2026 21:55
@tarrinneal tarrinneal added the CICD Run CI/CD label Oct 5, 2026
@tarrinneal tarrinneal added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Oct 5, 2026

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 5, 2026
@auto-submit
auto-submit Bot merged commit b6798fa into flutter:main Oct 5, 2026
14 checks passed
richyo-codes pushed a commit to richyo-codes/flutter that referenced this pull request Oct 7, 2026
…r#193919)

flutter/packages@951f2f7...7660d46

2026-10-06 [email protected] [image_picker] Document that retrieving
lost data is a one-time operation (flutter/packages#12784)
2026-10-05 [email protected] [shared_preferences] Document return values of
set and remove methods (flutter/packages#12303)
2026-10-05 [email protected] Redistribute package ownership among
Android team (flutter/packages#13138)
2026-10-05 [email protected] Remove redundant null
argument values across packages (flutter/packages#13115)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: shared_preferences

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants