Skip to content

Conversation

@tarrinneal
Copy link
Contributor

@tarrinneal tarrinneal commented Mar 15, 2023

Allows the use of custom prefixes for all platform (not relevant for windows and linux).

If no custom prefix is supplied, the default prefix flutter. will be used instead.

Fixes flutter/flutter#52544

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered having a defaultPrefix and a nullable prefix and checking to see if prefix were null instead. This seemed "more readable" so I went with this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be changed to an assert, or a state error if not set up correctly, similar to the main package setPrefix method

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

iOS LGTM

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

Web bits LGTM. Thanks for adding this feature!

(Small question about the need for the static setPrefix method)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feels particularly fragile at the moment, in the way it interacts with remove and setValue. I can rework the way the cached preferences are gotten to avoid this interaction if people agree that it's problematic here.

Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Looks good with a few last comments.

There are no comments at the platform interface level now though, so go ahead and split that out and we can get it approved and landed!

@tarrinneal
Copy link
Contributor Author

Looks good with a few last comments.

There are no comments at the platform interface level now though, so go ahead and split that out and we can get it approved and landed!

It's already up and ready, #3497

@tarrinneal
Copy link
Contributor Author

@stuartmorgan this is ready for final review

Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM! 🚢

@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 31, 2023
@auto-submit auto-submit bot merged commit 6502403 into flutter:main Mar 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 3, 2023
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
[shared_preferences] allow custom key prefixes
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 p: shared_preferences

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow setting prefix in shared preference - for migrating from old app that did not use flutter

4 participants