feat: Expose Flutter version in `flet.version` module (`FLUTTER_VERSION `) and cli (`--flutter-version`)
Copilot summary
This pull request introduces improvements to how the required Flutter SDK version is managed and propagated throughout the Python SDK and CLI, making the build process more robust and consistent. The Flutter version is now dynamically read from the .fvmrc file and patched into the Python package, ensuring that all tooling and commands use the correct version. Additionally, there are minor improvements and cleanups in CLI argument handling and code organization.
Flutter SDK Version Management:
- The
patch_python_package_versionsfunction in.github/scripts/common.shnow reads the Flutter version from.fvmrcusing a new script (read_fvmrc.py) and injects it intoflet/version.py, ensuring the Python SDK always knows the correct Flutter version. - The CLI (
flet-cli) commands now use the patchedFLUTTER_VERSIONfromflet.version, and all Flutter-related logic (installation, validation, prompts) references this dynamically set version instead of a hardcoded value.
CI/CD and Build Pipeline Adjustments:
- The GitHub Actions workflow (
ci.yml) is updated to ensure the environment is prepared with the correct Flutter version before building, and the working directory is set appropriately for each step. Redundant or misplaced version patching is removed from later build steps.
CLI and SDK Code Cleanups:
- CLI commands and utilities are refactored to consistently use the version from
flet.version, removing fallback logic and ensuring version consistency.
Examples
In a python file
import flet.version
print(f"Flet version: {flet.version.version} or {flet.__version__}")
print(f"Flutter version: {flet.version.FLUTTER_VERSION}")
CLI
flet build --flutter-version
GitHub Action
- name: Get Flutter version
shell: bash
run: |
uv venv
FLUTTER_VERSION="$( uv run python -c 'import flet.version; print(flet.version.FLUTTER_VERSION)' )"
echo "FLUTTER_VERSION=$FLUTTER_VERSION" >> "$GITHUB_ENV"
echo "Flutter version: $FLUTTER_VERSION"
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
cache: true
channel: stable
flutter-version: ${{ env.FLUTTER_VERSION }}
Summary by Sourcery
Expose and centralize version metadata for Flet, Flutter, and Pyodide, and wire it into the CLI, library API, and CI workflows.
New Features:
- Expose the required Flutter SDK version as flet.version.FLUTTER_VERSION and via the flet build --flutter-version CLI flag.
- Expose the Pyodide version as flet.version.PYODIDE_VERSION for use in tooling and CI.
- Export flet.version from the core package for standard version discovery.
- Export get_package_web_dir from flet_web for retrieving the embedded web assets directory.
Bug Fixes:
- Ensure Flet CLI commands consistently use a concrete Flet version string instead of falling back to Git at runtime when packaging or downloading clients.
Enhancements:
- Refine Flet version resolution logic to prefer a CI-injected value, fall back to Git tags in development, and use a stable default otherwise.
- Introduce helper functions to obtain Flet and Flutter versions and simplify template and packaging logic around those values.
- Derive the required Flutter SDK version from the repository .fvmrc (or CI-injected value) and enforce it in Flutter CLI workflows.
- Update CI scripts to patch Flutter and Pyodide versions dynamically from the Python package configuration rather than hard-coded values.
- Improve robustness of common.sh by making patch_python_package_versions fail fast and also patch the Flutter SDK version into version.py.
- Adjust various CLI messages and defaults for clarity and consistency, and tighten type hints around version handling.
Build:
- Update CI workflow steps and working directories to better integrate Python version patching and dynamic Pyodide version retrieval from flet.version.
CI:
- Have the web client CI job compute PYODIDE_VERSION from flet.version.PYODIDE_VERSION instead of a hard-coded environment value.
- Add a helper script read_fvmrc.py used in CI to read the Flutter version from .fvmrc and inject it into flet.version.FLUTTER_VERSION.
Documentation:
- Add inline documentation strings describing the Flet, Flutter, and Pyodide version constants and their intended usage in builds.
Deploying flet-docs with
Cloudflare Pages
| Latest commit: |
b44fe70
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2d6a2838.flet-docs.pages.dev |
| Branch Preview URL: | https://expose-flutter-version.flet-docs.pages.dev |
Instead of separate --flutter-version, --pyodide-version, --XXX-version options more "common" approach (what the most users would expect) is having a single --version option/command printing the versions of all components, like:
Flet: 1.2.3
Flutter: 3.4.5
Pyodide: 6.7.8
Even better, it could be version sub-command with some additional options:
-
--json- output in JSON format for scripts/CI. -
--verbose(orversion --verbose) to include extra detail (commit SHA, build date, platform, runtime paths).
I suggest we switch to version command.
Re: flet.version - I think we could have consistent identifiers for all Flet, Flutter and Pyodide versions:
flet.version.flet_version
flet.version.flutter_version
flet.version.pyodide_version
which could be used as:
from flet.version import flet_version, flutter_version, pyodide_version
inside flet.version we could have "private" constants:
_FLUTTER_VERSION = "3.38.0"
_PYODIDE_VERSION = "2.27.0"
...
right?