Skip to content

feat(FilePicker): add compression_quality and cancel_upload_on_window_blur to pick_files()#6573

Open
ndonkoHenri wants to merge 10 commits into
mainfrom
file-picker-improvements
Open

feat(FilePicker): add compression_quality and cancel_upload_on_window_blur to pick_files()#6573
ndonkoHenri wants to merge 10 commits into
mainfrom
file-picker-improvements

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Upgrades the file_picker package from ^10.3.10 to ^11.0.2 (migrating to its new static API — FilePicker.pickFiles() instead of FilePicker.platform.pickFiles()) and exposes some of its capabilities:

  • New FilePicker.pick_files() parameters:
    • compression_quality: int = 0 — image compression quality from 0 to 100, used on supported platforms. 0 (default) disables compression.
    • cancel_upload_on_window_blur: bool = True — web-only. Controls whether browser window blur is treated as a cancelled selection. Passing False prevents valid file selections from being reported as cancelled when the window loses focus during picking on slow machines or slow network shares. Fixes FilePicker times out when picking files on a slow network #771.
  • FilePicker.save_file() documentation now reflects actual desktop behavior: the dialog returns the chosen path and, if src_bytes is provided, those bytes are written to the selected file (instead of claiming the file is never created).
  • FloatingActionButtonLocation enum members now each have proper API docs instead of a bare link to the Flutter docs.

Summary by Sourcery

Add configurable image compression and window-blur handling to file picking, align FilePicker usage with the new static API, and improve related documentation.

New Features:

  • Expose a compression_quality parameter on FilePicker.pick_files() to control image compression level on supported platforms.
  • Expose a cancel_upload_on_window_blur parameter on FilePicker.pick_files() to control how web treats browser window blur during file selection.

Bug Fixes:

  • Prevent valid web file selections from being reported as cancelled on slow machines or network shares by allowing cancel_upload_on_window_blur to be disabled.

Enhancements:

  • Update FilePicker service to use the new static FilePicker API for picking, saving, and directory selection.
  • Enhance FloatingActionButtonLocation enum members with detailed API documentation for each location variant.

Build:

  • Bump the file_picker dependency from ^10.3.10 to ^11.0.2.

Documentation:

  • Clarify FilePicker.save_file() desktop behavior to note that providing src_bytes writes those bytes to the selected file.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8d005dc
Status: ✅  Deploy successful!
Preview URL: https://e2a4282a.flet-website-v2.pages.dev
Branch Preview URL: https://file-picker-improvements.flet-website-v2.pages.dev

View logs

@sourcery-ai sourcery-ai 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.

We've reviewed this pull request using the Sourcery rules engine

Copilot AI 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.

Pull request overview

This PR upgrades the Flutter file_picker dependency and adapts the Dart service to the new static FilePicker.* API, while exposing new pick_files() capabilities to the Python SDK and improving related API documentation.

Changes:

  • Bump Flutter file_picker from ^10.3.10 to ^11.0.2 and migrate service calls to FilePicker.pickFiles()/saveFile()/getDirectoryPath().
  • Add compression_quality and cancel_upload_on_window_blur parameters to Python FilePicker.pick_files() and forward them through to the Flutter service.
  • Improve Python API documentation (FilePicker.save_file behavior; richer docs for FloatingActionButtonLocation enum members).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/python/packages/flet/src/flet/controls/types.py Adds detailed per-enum-member docs for FloatingActionButtonLocation.
sdk/python/packages/flet/src/flet/controls/services/file_picker.py Adds new pick_files() parameters, forwards them to the backend, and updates save_file() docs.
packages/flet/pubspec.yaml Upgrades file_picker dependency to ^11.0.2.
packages/flet/lib/src/services/file_picker.dart Migrates to FilePicker static API and wires new pick-files arguments.
CHANGELOG.md Documents the new parameters and the web blur-cancel workaround (Issue #771).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/flet/lib/src/services/file_picker.dart
Comment thread packages/flet/lib/src/services/file_picker.dart
Comment thread sdk/python/packages/flet/src/flet/controls/services/file_picker.py
ndonkoHenri and others added 4 commits June 11, 2026 14:27
* Remove Canvaskit web build artifacts

Delete generated web/canvaskit build artifacts from sdk/python/templates/build/{{cookiecutter.out_dir}} (canvaskit.js, .symbols, .wasm and chromium/skwasm variants). These are built/WebAssembly output files and have been removed from the template to avoid committing generated binaries and reduce repository/template size.

* feat(build): multi-version Python support (3.12 / 3.13 / 3.14)

Add a `python_versions` registry that maps each supported short Python
version to its CPython-standalone build, Pyodide release, and Emscripten
wheel platform tag. `flet build` and `flet publish` resolve the version
in this order: `--python-version X.Y` (new flag) -> `[project].requires-
python` (highest matching stable; pre-release rows are skipped unless an
explicit specifier like `==3.15.*` opts in) -> default `3.14`.

`build_base.py` threads the resolved version through to serious_python
(via `--python-version` and `SERIOUS_PYTHON_VERSION`) and the Flutter
build env, and exposes it to the cookiecutter template as
`cookiecutter.options.python_version` so the Android `abiFilters` can
drop `armeabi-v7a` for 3.13+ (PEP 738 dropped 32-bit Android in
python-build releases).

Pyodide is no longer pre-baked into the build template. On each web
build/publish, the matching pyodide-core tarball plus the micropip /
packaging wheels are downloaded into the build output and cached under
`~/.flet/pyodide/<version>/`. `client/web/python.js` and the templated
`python.js` drop the hardcoded `defaultPyodideUrl`; `patch_index.py`
injects `flet.pyodideUrl` at build time (CDN for normal builds, local
`pyodide/pyodide.js` when `--no-cdn`).

Other:

* Bump the `serious_python` pin in the build template to 2.0.0
  (multi-version support landed there as a breaking release; pin must
  follow once 2.0.0 is published to pub.dev).
* Add `python_version`-aware section to the publish docs ("Choosing a
  Python version"), Pyodide pairing table on the static-website page,
  and a `--pre` clarification on `flet publish`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* flet --version: list supported Python versions instead of a static Pyodide

With multi-version Python, Pyodide is selected per build from
`SUPPORTED_PYTHON_VERSIONS` (currently 0.27.7 / 0.29.4 / 314.0.0a2 for
Python 3.12 / 3.13 / 3.14). The old single-line `Pyodide: 0.27.7` field
on `flet.version` was both stale and misleading once it stopped tracking
what `flet build` actually bundles.

Replace it with a multi-line listing rendered from the registry:

    Flet: 0.85.3
    Flutter: 3.41.7
    Supported Python versions:
      3.12 (Pyodide 0.27.7)
      3.13 (Pyodide 0.29.4)
      3.14 (Pyodide 314.0.0a2, default)

Pre-release rows render with ", pre-release" appended. `PYODIDE_VERSION`
and the `pyodide_version` export on `flet.version` are removed (the only
external consumer was the CLI version output, now updated).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* flet --version: list supported Python versions newest first

Sort SUPPORTED_PYTHON_VERSIONS by `packaging.version.Version(r.short)`
in reverse before rendering, so users see the default (newest stable) at
the top instead of having to scan to the bottom of the list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(build): use Path.as_uri() for dev-package file:// URLs on Windows

`flet build` rewrites local-path dev dependencies as `<pkg> @
file://<path>` so pip installs them in place. On Windows the literal
f"file://{dev_path}" rendered `file://D:\a\...\flet`, which pip parsed
as a UNC path (`\\D:\a\...`) and failed with:

  ERROR: Could not install packages due to an OSError: [Errno 2]
  No such file or directory: '\\\\D:\\a\\flet\\flet\\sdk\\python\\packages\\flet'

`Path.as_uri()` produces the correct three-slash form
(`file:///D:/a/flet/...` on Windows, `file:///Users/...` on POSIX) and
URL-encodes any special characters, so it's safe on every platform.

Surfaces on flet's own apk-windows CI job
(flet-dev/flet#27111512526 job 80010220246).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* ci(flet-build-test): exercise full Python matrix (3.12 / 3.13 / 3.14)

Each of the 14 build targets (linux/macos/windows + Android aab+apk on
all three hosts + ipa + ios-simulator + web on all three hosts) now runs
against every supported bundled CPython, producing 42 jobs total.

Matrix gains a `python_version` scalar axis and promotes `name` from an
`include` row to a base axis so GH Actions takes the cartesian product;
the existing `include` entries are kept as-is and matched by `name` to
supply per-target runner / build_cmd / artifact_path. The build step now
passes `--python-version ${{ matrix.python_version }}` to `flet build`,
and the upload step disambiguates the artifact name with a `-pyX.Y`
suffix so the 42 uploads don't collide.

`fail-fast: false` is unchanged so a single failing combo doesn't kill
the rest of the grid.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* ci(flet-build-test): group build jobs per Python via reusable workflow

Split the 14-target build matrix into a reusable workflow
(`flet-build-test-matrix.yml`) that takes the bundled Python version as
an input, and call it three times from the entrypoint — once per
supported CPython release. The Actions UI now renders each call as its
own collapsible "Matrix: build" card (`0/14 jobs completed`) instead of
a single flat 42-row list.

Adds a `python_version` choice input to `workflow_dispatch` (`all` |
`3.12` | `3.13` | `3.14`) so manual runs can target a single version.
push and pull_request triggers always fire all three. Each call is
gated by `if: github.event_name != 'workflow_dispatch' || inputs.python_version == 'all' || inputs.python_version == 'X.Y'`.

The pack job stays at the top level (its host-Python PyInstaller bundle
is independent of the bundled CPython that `flet build` ships, so it
doesn't need a per-Python axis). path-filter triggers now reference
both workflow files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Prepare release 0.86.0 (multi-version bundled Python)

Bumps the Dart-side `flet` package to 0.86.0 and adds the user-facing
0.86.0 entry to the top-level changelog: new `--python-version` flag,
per-version Pyodide download/cache, `flet --version` listing change,
the default-3.14 breaking note, removal of `flet.version.pyodide_version`,
and the Windows `file://` dev-package URL fix. The Dart `flet` package
gets the usual italic release-coordination note since this branch
doesn't touch the Dart side.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs: sort Python version tables newest first

Match the same descending order applied to `flet --version` so users see
the default (3.14) at the top of every supported-Python table instead of
having to scan to the bottom of the list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FilePicker times out when picking files on a slow network

3 participants