-
Notifications
You must be signed in to change notification settings - Fork 600
v1: Delegate icons creation to extensions #5556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replaces shell scripts with a unified Python script using Jinja2 templates for icon generation. Adds template files and generated icon lists for both Material and Cupertino icons in Dart and Python. Updates Flet core extension to use icon indices instead of codepoints, simplifying icon lookup and usage. Removes legacy generated icon files and updates build scripts to remove '--no-tree-shake-icons' flag.
Wrapped the ft.run(main) call in a __name__ == "__main__" guard to prevent unintended execution when the module is imported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @FeodorFitsner, your pull request is too large to review
There was a problem hiding this 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 implements a new architecture for icon creation by delegating icon generation to extensions, replacing the previous string-based icon system with a numeric encoding scheme. The change introduces a new IconData base class and restructures icon handling across the Flet codebase.
- Replaced string-based icon identifiers with numeric encoding using
IconDatatype - Implemented icon creation delegation to extensions through new
createIconDatamethod - Updated all icon-related type annotations from
IconValue/IconValueOrControltoIconData/IconDataOrControl
Reviewed Changes
Copilot reviewed 77 out of 83 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/python/packages/flet/src/flet/controls/icon_data.py | New IconData base class with numeric encoding and random selection methods |
| packages/flet/lib/src/flet_extension.dart | Added createIconData method for delegating icon creation to extensions |
| packages/flet/lib/src/utils/icons.dart | Updated icon parsing to use numeric codes and extension delegation |
| Multiple control files | Updated type annotations from IconValue to IconData throughout codebase |
| ci/generate_icons.py | New icon generation script using templates and numeric encoding |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Uncommented and enabled flet_datatable2 in main.dart and pubspec.yaml, switching its git ref to 'main'. Updated several other Flet package refs from 'v1' to 'main' and bumped various dependency versions in pubspec.lock for compatibility with Dart >=3.8.0.
Deploying flet-docs with
|
| Latest commit: |
0800967
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fd82409a.flet-docs.pages.dev |
| Branch Preview URL: | https://v1-icons-codepoint.flet-docs.pages.dev |
Updated CupertinoIcons and Icons classes to include package_name and class_name metadata via IconData's __init_subclass__ method. This change enables better identification and organization of icon sets within the Flet framework.
Added comments in Dart files to explain icon integer encoding as (set_id << 16 | index). Updated Python docstring to clarify encoding structure: lower 16 bits for icon index and bits 16-24 for set ID, replacing previous code point-based description.
Updated CupertinoIcons and Icons classes to include package_name and class_name arguments in their inheritance. This change clarifies the source and identity of the icon sets for downstream usage.
The 'ci/templates' directory is no longer excluded from Ruff linting in pyproject.toml, allowing lint checks to be performed on files in this directory.
Updated icon construction logic in navigation bar controls to use buildIconOrWidget for consistency. Improved and clarified docstrings for Icon and NavigationBarDestination classes in Python, including parameter explanations and accessibility notes. Refactored theme parsing for switch themes to simplify argument usage. Minor formatting and doc improvements in CupertinoNavigationBar and IconData.
Close #5468
This pull request refactors the icon generation and usage system in the codebase, moving from custom shell scripts and regex-based parsing to a unified Python script with Jinja2 templates. It also updates the way icons are referenced in Dart code, improving maintainability and consistency across both Dart and Python SDKs. Additionally, it removes the dependency on the
flet_datatable2package and updates the.ruff.tomlconfiguration.Icon generation and usage refactor:
ci/generate_icons.pythat downloads icon definitions from Flutter, parses them, and generates both Dart and Python icon files using Jinja2 templates. This replaces multiple shell scripts previously used for icon generation.ci/templates/material_icons.dart,ci/templates/cupertino_icons.dart,ci/templates/material_icons.py, andci/templates/cupertino_icons.py. These templates ensure consistent formatting and easier updates. [1] [2] [3] [4]ci/generate_material_icons_dart.sh,ci/generate_material_icons_python.sh,ci/generate_cupertino_icons_dart.sh, andci/generate_cupertino_icons_python.sh. [1] [2] [3] [4]Codebase updates for icon usage:
packages/flet/lib/src/controls) to usegetIconDataand integer-based icon references, ensuring compatibility with the new icon system. [1] [2] [3] [4] [5] [6] [7] [8]packages/flet/lib/flet.dartto use Flutter's built-inCupertinoIconsandIconsinstead of custom icon maps. [1] [2]Dependency and configuration cleanup:
flet_datatable2package fromclient/pubspec.yamland commented out its usage inclient/lib/main.dart. [1] [2] [3].ruff.tomlto exclude theci/templatesdirectory from linting.