Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shared_preferences] Adds Shared preferences as option in shared preferences async android #7994

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tarrinneal
Copy link
Contributor

@tarrinneal tarrinneal commented Nov 1, 2024

Adds the ability to select which Android preferences backend (SharedPreferences or DataStore Preferences) one would like to use.

Also adds the ability to pick a file name for the shared preferences backend.

fixes flutter/flutter#153300
fixes flutter/flutter#14337

@tarrinneal tarrinneal changed the title [shared_preferences] Shared preferences shared preferences [shared_preferences] Adds Shared preferences as option in shared preferences async android Nov 19, 2024
@tarrinneal tarrinneal force-pushed the shared-preferences-shared-preferences branch from 978df17 to 99f76da Compare November 19, 2024 22:32
@tarrinneal tarrinneal marked this pull request as ready for review November 19, 2024 23:47
packages/shared_preferences/shared_preferences/README.md Outdated Show resolved Hide resolved
packages/shared_preferences/shared_preferences/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to the integration test suggestion, we should have a unit test that writes directly to the default SP store, and then reads it back via backend.

return SharedPreferencesPigeonOptions();
}

SharedPreferencesAsyncApi _getApiForBackend(
SharedPreferencesPigeonOptions options) {
return options.useDataStore ? _dataStoreApi : _sharedPreferencesApi;
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of the same API with different suffixes so you could switch in a single place is very clever!

@tarrinneal tarrinneal force-pushed the shared-preferences-shared-preferences branch from de43522 to 95eb61e Compare November 26, 2024 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants