feat(clipboard): add image and file set/get APIs#6141
feat(clipboard): add image and file set/get APIs#6141ndonkoHenri wants to merge 20 commits intomainfrom
Conversation
Deploying flet-docs with
|
| Latest commit: |
2fe5a57
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2749b71d.flet-docs.pages.dev |
| Branch Preview URL: | https://improve-clipboard.flet-docs.pages.dev |
Deploying flet-examples with
|
| Latest commit: |
2fe5a57
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dbbc2bfb.flet-examples.pages.dev |
| Branch Preview URL: | https://improve-clipboard.flet-examples.pages.dev |
There was a problem hiding this comment.
Pull request overview
Adds new clipboard capabilities (images + file references) to Flet by extending the Python Clipboard service API and implementing corresponding Flutter-side handlers, alongside new integration tests and examples.
Changes:
- Extend Python
Clipboardservice withset_image/get_imageandset_files/get_filesAPIs, plus updated docs/examples. - Implement new clipboard method handlers on the Flutter client using the
pasteboardplugin and add supporting utility changes. - Add/enable integration tests for services (clipboard, battery, storage paths, shared preferences) and CI wiring.
Reviewed changes
Copilot reviewed 27 out of 30 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/python/packages/flet/src/flet/controls/services/clipboard.py | Adds image/file clipboard APIs and platform guards to Python service layer. |
| sdk/python/packages/flet/integration_tests/controls/services/test_storage_paths.py | Adds integration coverage for StoragePaths across supported/unsupported platforms. |
| sdk/python/packages/flet/integration_tests/controls/services/test_shared_preferences.py | Adds CRUD integration coverage for SharedPreferences. |
| sdk/python/packages/flet/integration_tests/controls/services/test_clipboard.py | Adds integration coverage for clipboard text/image/files behavior. |
| sdk/python/packages/flet/integration_tests/controls/services/test_battery.py | Adds integration coverage for Battery service. |
| sdk/python/packages/flet/integration_tests/conftest.py | Ensures ft.context.page is set during tests and prevents context leakage. |
| sdk/python/packages/flet/integration_tests/README.md | Documents how to run the new services integration tests. |
| sdk/python/packages/flet/docs/services/clipboard.md | Updates clipboard docs to include strings/images/files examples. |
| sdk/python/examples/services/clipboard/strings.py | Updates strings example to use controls=[...] argument style. |
| sdk/python/examples/services/clipboard/images.py | New example demonstrating image clipboard set/get. |
| sdk/python/examples/services/clipboard/files.py | New example demonstrating file reference clipboard set/get. |
| sdk/python/examples/controls/alert_dialog/media/modal_and_non_modal.gif | Media asset change included in PR. |
| sdk/python/examples/apps/flet_build_test/pyproject.toml | Adds Flutter dependency override for local flet package in build test app. |
| packages/flet/pubspec.yaml | Adds pasteboard dependency to enable image/files clipboard support. |
| packages/flet/lib/src/utils/images.dart | Exposes a reusable convertToUint8List() helper (rename from private). |
| packages/flet/lib/src/services/clipboard.dart | Implements new clipboard methods via pasteboard plugin. |
| packages/flet/lib/src/controls/cupertino_textfield.dart | Fixes box shadow property lookup key (shadow → shadows). |
| client/windows/flutter/generated_plugins.cmake | Registers pasteboard plugin for Windows client. |
| client/windows/flutter/generated_plugin_registrant.cc | Registers pasteboard plugin for Windows client (C++ registrant). |
| client/pubspec.lock | Records resolved pasteboard dependency in the client lockfile. |
| client/macos/Flutter/GeneratedPluginRegistrant.swift | Registers pasteboard plugin for macOS client. |
| client/linux/flutter/generated_plugins.cmake | Registers pasteboard plugin for Linux client. |
| client/linux/flutter/generated_plugin_registrant.cc | Registers pasteboard plugin for Linux client (C++ registrant). |
| client/ios/Runner.xcodeproj/project.pbxproj | Bumps iOS deployment target in Xcode project settings. |
| client/ios/Podfile.lock | Updates iOS pods lockfile to include new/updated dependencies. |
| client/ios/Podfile | Sets iOS platform minimum version to 14.0. |
| client/ios/Flutter/AppFrameworkInfo.plist | Bumps MinimumOSVersion to 14.0. |
| client/android/app/src/main/res/xml/provider_paths.xml | Adds FileProvider paths configuration used for file URI sharing. |
| client/android/app/src/main/AndroidManifest.xml | Adds FileProvider entry to support file URI grants. |
| .github/workflows/macos-integration-tests.yml | Enables running services integration tests in macOS CI job. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
client/ios/Podfile
Outdated
| @@ -1,5 +1,5 @@ | |||
| # Uncomment this line to define a global platform for your project | |||
| # platform :ios, '13.0' | |||
| platform :ios, '14.0' | |||
There was a problem hiding this comment.
This PR bumps the iOS minimum deployment target to 14.0. That’s a breaking platform support change and isn’t mentioned in the PR description; please document the requirement (e.g., dependency constraint from pasteboard) and confirm dropping iOS 13 is intended for all clients.
| from flet.controls.exceptions import FletUnimplementedPlatformException | ||
| from flet.controls.services.service import Service | ||
| from flet.controls.types import PagePlatform |
There was a problem hiding this comment.
Platform checks in services typically raise FletUnsupportedPlatformException (meaning the operation isn’t supported), whereas FletUnimplementedPlatformException is documented as “not implemented yet”. Since these clipboard APIs are implemented on some platforms, consider switching to FletUnsupportedPlatformException (and updating the docstrings accordingly) for consistency with other services (e.g., StoragePaths).
|
|
||
| Raises: | ||
| FletUnimplementedPlatformException: If called on platforms other than the | ||
| following: Android, iOS, Web. | ||
| """ | ||
| if not (self.page.web or self.page.platform.is_mobile()): | ||
| raise FletUnimplementedPlatformException( | ||
| "set_image is not supported on this platform" | ||
| ) |
There was a problem hiding this comment.
The Python API currently blocks set_image() on desktop platforms, but the Flutter backend implements the "set_image" method unconditionally. Unless there’s a known platform limitation, this guard will unnecessarily prevent desktop usage and make the Python-side supported-platform list diverge from the backend.
| Raises: | |
| FletUnimplementedPlatformException: If called on platforms other than the | |
| following: Android, iOS, Web. | |
| """ | |
| if not (self.page.web or self.page.platform.is_mobile()): | |
| raise FletUnimplementedPlatformException( | |
| "set_image is not supported on this platform" | |
| ) | |
| """ |
| assert await prefs.contains_key(key_1) is False | ||
| assert await prefs.set(key_1, "value-1") is True | ||
| assert await prefs.set(key_2, "value-2") is True | ||
| assert await prefs.get(key_1) == "value-1" | ||
| assert await prefs.contains_key(key_1) is True | ||
|
|
||
| keys = await prefs.get_keys(prefix) | ||
| assert key_1 in keys | ||
| assert key_2 in keys | ||
|
|
||
| assert await prefs.remove(key_1) is True | ||
| assert await prefs.contains_key(key_1) is False | ||
| assert await prefs.get(key_1) is None | ||
|
|
||
| assert await prefs.clear() is True | ||
| assert await prefs.get(key_2) is None |
There was a problem hiding this comment.
This 'assert' statement contains an expression which may have side effects.
| assert await prefs.contains_key(key_1) is False | |
| assert await prefs.set(key_1, "value-1") is True | |
| assert await prefs.set(key_2, "value-2") is True | |
| assert await prefs.get(key_1) == "value-1" | |
| assert await prefs.contains_key(key_1) is True | |
| keys = await prefs.get_keys(prefix) | |
| assert key_1 in keys | |
| assert key_2 in keys | |
| assert await prefs.remove(key_1) is True | |
| assert await prefs.contains_key(key_1) is False | |
| assert await prefs.get(key_1) is None | |
| assert await prefs.clear() is True | |
| assert await prefs.get(key_2) is None | |
| contains_1_initial = await prefs.contains_key(key_1) | |
| assert contains_1_initial is False | |
| set_1_result = await prefs.set(key_1, "value-1") | |
| assert set_1_result is True | |
| set_2_result = await prefs.set(key_2, "value-2") | |
| assert set_2_result is True | |
| value_1 = await prefs.get(key_1) | |
| assert value_1 == "value-1" | |
| contains_1_after_set = await prefs.contains_key(key_1) | |
| assert contains_1_after_set is True | |
| keys = await prefs.get_keys(prefix) | |
| assert key_1 in keys | |
| assert key_2 in keys | |
| removed = await prefs.remove(key_1) | |
| assert removed is True | |
| contains_1_after_remove = await prefs.contains_key(key_1) | |
| assert contains_1_after_remove is False | |
| value_1_after_remove = await prefs.get(key_1) | |
| assert value_1_after_remove is None | |
| cleared = await prefs.clear() | |
| assert cleared is True | |
| value_2_after_clear = await prefs.get(key_2) | |
| assert value_2_after_clear is None |
This reverts commit 495daf6.
… flet-color-pickers to extensions dep-group
Fix #349
Related to flet-dev/flet-build-template#75
Test code
Details
Summary by Sourcery
Add cross-platform clipboard support for images and files and strengthen service-related testing and platform integration.
New Features:
Bug Fixes:
Enhancements:
Build:
CI:
Documentation:
Tests: