Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Dec 16, 2025

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_versions function in .github/scripts/common.sh now reads the Flutter version from .fvmrc using a new script (read_fvmrc.py) and injects it into flet/version.py, ensuring the Python SDK always knows the correct Flutter version.
  • The CLI (flet-cli) commands now use the patched FLUTTER_VERSION from flet.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.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 16, 2025

Deploying flet-docs with Β Cloudflare Pages Β Cloudflare Pages

Latest commit: 0662abe
Status:Β βœ…Β  Deploy successful!
Preview URL: https://e4634b7f.flet-docs.pages.dev
Branch Preview URL: https://expose-flutter-version.flet-docs.pages.dev

View logs

Copy link
Contributor

Copilot AI left a comment

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 exposes the Flutter SDK version used by Flet through a new FLUTTER_VERSION constant in the flet.version module and a --flutter-version CLI flag. This enables users and CI systems to programmatically determine the required Flutter SDK version for building Flet apps.

Key Changes:

  • Added FLUTTER_VERSION constant and get_flutter_version() function to flet.version module with CI patching and .fvmrc fallback
  • Added --flutter-version CLI argument to flet build command to print the required Flutter SDK version
  • Refactored version detection logic to use dedicated getter functions instead of conditional inline checks

Reviewed changes

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

Show a summary per file
File Description
sdk/python/packages/flet/src/flet/version.py Added FLUTTER_VERSION constant, PYODIDE_VERSION constant, and getter functions for version retrieval with fallback logic
sdk/python/packages/flet/src/flet/__init__.py Exported __version__ following Python package conventions
sdk/python/packages/flet-web/src/flet_web/__init__.py Added get_package_web_dir to __all__ exports
sdk/python/packages/flet-desktop/src/flet_desktop/__init__.py Simplified version retrieval by removing redundant from_git() fallback
sdk/python/packages/flet-cli/src/flet_cli/commands/serve.py Reformatted long string for better readability
sdk/python/packages/flet-cli/src/flet_cli/commands/publish.py Changed route URL strategy to use proper RouteUrlStrategy type instead of string
sdk/python/packages/flet-cli/src/flet_cli/commands/flutter_base.py Refactored to use flet.version.FLUTTER_VERSION and store required version as instance variable
sdk/python/packages/flet-cli/src/flet_cli/commands/doctor.py Simplified Flet version display logic
sdk/python/packages/flet-cli/src/flet_cli/commands/devices.py Removed trailing periods from help messages for consistency
sdk/python/packages/flet-cli/src/flet_cli/commands/create.py Simplified template reference logic using guaranteed non-empty version
sdk/python/packages/flet-cli/src/flet_cli/commands/build_base.py Removed duplicate PYODIDE_ROOT_URL constant and simplified version checks
sdk/python/packages/flet-cli/src/flet_cli/commands/build.py Added --flutter-version CLI argument for version display
.github/workflows/ci.yml Updated Python version to 3.12.7, added Pyodide version extraction from flet.version, and improved working directory consistency
.github/scripts/read_fvmrc.py New utility script to read Flutter version from .fvmrc file
.github/scripts/common.sh Enhanced version patching to include Flutter SDK version from .fvmrc, converted to subshell for safer execution

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@FeodorFitsner
Copy link
Contributor

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 (or version --verbose) to include extra detail (commit SHA, build date, platform, runtime paths).

I suggest we switch to version command.

@FeodorFitsner
Copy link
Contributor

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?

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

New security issues found

Comment on lines 9 to 11
retcode = subprocess.call(
[
sys.executable,
Copy link
Contributor

Choose a reason for hiding this comment

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

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'call' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

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.

3 participants