feat: make SharedPreferences support int, float, bool and list[str]#6267
feat: make SharedPreferences support int, float, bool and list[str]#6267ndonkoHenri wants to merge 8 commits intomainfrom
SharedPreferences support int, float, bool and list[str]#6267Conversation
…double, List<String>)
There was a problem hiding this comment.
Pull request overview
This PR expands SharedPreferences to support additional primitive value types end-to-end (Python SDK ↔ Flutter service), while also updating build CLI boolean parsing/help text and making several documentation improvements (publish guides + cookbook).
Changes:
- Extend
SharedPreferencesto supportint,float,bool, andlist[str](Python typing + Dart service implementation) and broaden integration test coverage. - Update
flet buildCLI boolean parsing to be case-insensitive for several flags and align related publish documentation/examples. - Add a new cookbook article (
Subprocess) and update MkDocs navigation; apply assorted docs/changelog/lockfile maintenance updates.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/python/packages/flet/src/flet/controls/services/shared_preferences.py | Adds a SharedPreferencesValueType alias, tighter input validation, and improved docstrings. |
| packages/flet/lib/src/services/shared_preferences.dart | Implements multi-type set/get support using the platform shared_preferences API. |
| sdk/python/packages/flet/integration_tests/controls/services/test_shared_preferences.py | Extends CRUD integration test to cover new supported types and invalid inputs. |
| sdk/python/packages/flet-cli/src/flet_cli/commands/build_base.py | Makes several CLI boolean parsers case-insensitive and tweaks help text. |
| sdk/python/packages/flet/src/flet/auth/authorization_service.py | Adds an explicit return type to get_token(). |
| sdk/python/packages/flet/docs/publish/android.md | Docs updates for resolution order, boolean forms, and “template translation” examples. |
| sdk/python/packages/flet/docs/publish/ios.md | Docs updates for supported forms/examples and template-translation sections. |
| sdk/python/packages/flet/docs/publish/macos.md | Docs updates for supported forms/examples and template-translation sections. |
| sdk/python/packages/flet/docs/publish/index.md | Adds “template translation” details and updates deep-linking references/links. |
| sdk/python/packages/flet/docs/cookbook/subprocess.md | New cookbook recipe covering subprocess usage (non-web). |
| sdk/python/packages/flet/docs/cookbook/assets.md | Updates control link format for Image. |
| sdk/python/packages/flet/mkdocs.yml | Adds the new Subprocess cookbook page to navigation. |
| sdk/python/packages/flet-cli/src/flet_cli/commands/build.py | Adds a publish documentation link in the command docstring. |
| sdk/python/packages/flet-ads/CHANGELOG.md | Changelog entry formatting/version section update. |
| client/pubspec.lock | Updates pinned Dart transitive dependencies. |
| .codex/skills/prepare-flet-release/SKILL.md | Tightens release-prep instructions (author attribution + changelog scan guidance). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| i = p.find("=") | ||
| if i > -1: | ||
| macos_entitlements[p[:i]] = p[i + 1 :] == "True" | ||
| macos_entitlements[p[:i]] = p[i + 1 :].strip().lower() == "true" |
There was a problem hiding this comment.
--macos-entitlements values are parsed as ... == "true", which silently treats any other value (e.g. foo) as False. This contradicts the CLI/docs wording that only true/false are accepted and can mask user mistakes; consider validating the value and failing with cleanup() when it’s not one of {true,false} (similar to the --info-plist parsing above).
| macos_entitlements[p[:i]] = p[i + 1 :].strip().lower() == "true" | |
| k = p[:i] | |
| v = p[i + 1 :].strip() | |
| v_lower = v.lower() | |
| if v_lower in {"true", "false"}: | |
| macos_entitlements[k] = v_lower == "true" | |
| else: | |
| self.cleanup(1, f"Invalid macOS entitlement value: {p}") |
| i = p.find("=") | ||
| if i > -1: | ||
| android_permissions[p[:i]] = p[i + 1 :] == "True" | ||
| android_permissions[p[:i]] = p[i + 1 :].strip().lower() == "true" |
There was a problem hiding this comment.
--android-permissions parsing treats any value other than case-insensitive true as False. If a user passes an invalid token (typo), it will be accepted and flipped to False; please validate values and error out unless the value is true/false.
| android_permissions[p[:i]] = p[i + 1 :].strip().lower() == "true" | |
| key = p[:i] | |
| value_str = p[i + 1 :].strip() | |
| value_lc = value_str.lower() | |
| if value_lc in {"true", "false"}: | |
| android_permissions[key] = value_lc == "true" | |
| else: | |
| self.cleanup( | |
| 1, | |
| f"Invalid Android permission value for {key}: {value_str}", | |
| ) |
| i = p.find("=") | ||
| if i > -1: | ||
| android_features[p[:i]] = p[i + 1 :] == "True" | ||
| android_features[p[:i]] = p[i + 1 :].strip().lower() == "true" |
There was a problem hiding this comment.
--android-features parsing currently accepts arbitrary values and maps them to False unless they equal true (case-insensitive). To avoid surprising behavior and to match the documented true|false contract, validate the value and fail fast when it’s not true or false.
| android_features[p[:i]] = p[i + 1 :].strip().lower() == "true" | |
| value_str = p[i + 1 :].strip() | |
| value_normalized = value_str.lower() | |
| if value_normalized not in ("true", "false"): | |
| self.cleanup( | |
| 1, | |
| f"Invalid Android feature value for '{p[:i]}': '{value_str}'. Expected 'true' or 'false'.", | |
| ) | |
| android_features[p[:i]] = value_normalized == "true" |
|
|
||
| Raises: | ||
| ValueError: If `value` is of an unsupported type | ||
| `(`str`, `int`, `float`, `bool`, and `list[str]`)` |
There was a problem hiding this comment.
The Raises: section has malformed inline-code formatting: the supported-type list is wrapped in nested backticks and parentheses, which renders poorly in generated docs. Please rewrite the supported types list without the extra outer backticks/parentheses so it formats cleanly.
| `(`str`, `int`, `float`, `bool`, and `list[str]`)` | |
| (`str`, `int`, `float`, `bool`, and `list[str]`). |
| flet build ipa \ | ||
| --info-plist NSCameraUsageDescription="This app uses needs camera access." \ | ||
| --info-plist UIFileSharingEnabled=true |
There was a problem hiding this comment.
The example text "This app uses needs camera access." is grammatically incorrect and is repeated in CLI/TOML/XML examples in this section. Please change it to something like "This app needs camera access." consistently.
| def open_settings(e): | ||
| result = subprocess.run( | ||
| ["am", "start", "-n", "com.android.settings/.Settings", "--user", "0"], | ||
| shell=False, # default |
There was a problem hiding this comment.
There is a stray tab character before shell=False in the Python example, which makes the snippet look misindented when copied/pasted. Please replace it with spaces to keep formatting consistent.
| shell=False, # default | |
| shell=False, # default |
| - PubSub: cookbook/pub-sub.md | ||
| - Read and Write Files: cookbook/read-and-write-files.md | ||
| - Session Storage: cookbook/session-storage.md | ||
| - Subprocess: cookbook/subprocess.md | ||
| - Theming: cookbook/theming.md |
There was a problem hiding this comment.
The PR title is scoped to SharedPreferences type support, but this PR also changes CLI build boolean parsing, multiple publish docs pages, adds a new cookbook article, updates a Dart lockfile, and modifies release automation docs. Please either split these into focused PRs or update the PR title/description to reflect the broader scope so reviewers can assess impact appropriately.
Summary by Sourcery
Extend SharedPreferences to support multiple primitive types and lists while improving platform build configuration handling and documentation.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: