.agents/skills/create-flet-example-projects/SKILL.md
Use this skill when a user asks to:
examples/controls/chip) in the project-per-example formatEnsure each runnable example is a standalone project containing:
main.pypyproject.toml with Gallery/MCP metadataassets/ (if the example uses local assets)foo.pyfoo/main.py*.py in the target folder (exclude helper files such as __init__.py).media/ unless an example needs local assets copied into its own assets/.foo.py, create foo/ and move file to foo/main.py.foo/main.py already exists, keep it and do not recreate/move files.main.py is missing, repair structure only when there is a clear source file.foo/__init__.py; import example modules directly in tests/docs (for example import examples.controls.foo.bar.main as bar or import examples.controls.foo.bar as bar when using namespace-package imports).examples/controls/<control>/__init__.py too. The converted folders should behave like namespace packages, matching prior migrations such as commit 7e65ad566.pyproject.toml for each example project.pyproject.toml files for existing project folders.[tool.flet].platforms:
[tool.flet].platforms with only the supported platforms.[tool.flet].platforms.[project]: name, version, description, requires-python, keywords, authors, dependencies[dependency-groups].dev: include flet-cli, flet-desktop, flet-web[tool.flet.gallery].categories[tool.flet.metadata]: title, controls, layout_pattern, complexity, features[tool.flet]: org, company, copyright[tool.flet].platforms only when the example is platform-limited.[project].description must be meaningful and example-specific; avoid generic placeholders like "Example N" or "<name> example for <control>".Input/Chip, plus optional Apps/Basic controls.filter-bar, inline-actions, dashboard, list-detail).basic unless logic/state/architecture is non-trivial."save to file" in [tool.flet.metadata].features.async def handlers or async control flow, append "async" to keywords.flet for standard examples.If ft.context.disable_auto_update() is not used, do not add explicit page.update() unless strictly necessary.
Apply this page.update() rule to all examples in the touched folder (new, migrated, and already converted).
Wrap app content in ft.SafeArea so example renders correctly on mobile.
Add expand=True to ft.SafeArea only when needed for correct layout/sizing (for example to avoid Infinity/NaN sizing issues), and avoid adding it when not necessary.
When converting legacy page.add(a, b, ...) style examples, wrap the controls in ft.Column(controls=[...]) inside ft.SafeArea(content=...) rather than ft.Row, unless the original code explicitly used a row layout.
Apply this to all examples in the touched folder (new, migrated, and already converted), not only files changed by moves.
During validation, confirm every <example>/main.py in scope includes a top-level ft.SafeArea around rendered content.
For declarative examples using @ft.component, do not pass component instances as regular control children (for example SafeArea(content=App())) because this can raise runtime attribute errors.
In declarative examples, ensure the component itself returns regular controls (including SafeArea when needed) and render it at page level with page.render(App) in main().
@ft.control for custom controls in examples.class MyThing(ft.Column)), prefer @ft.control style.init() where practical.use_material3 appears in example code, remove it and simplify the example to current API usage.use_material3.pyproject.toml) to remove stale Material 3 references when code is changed.main.py should end with:
if __name__ == "__main__": ft.run(main).../example.py to .../example/main.py.sdk/python/packages/flet/docs/controls/<control>.md) and update any --8<-- includes or direct file-path references to the new main.py path.__init__.py re-exports.__init__.py, confirm no remaining imports rely on from examples.controls.<control> import ....python -m compileall on changed main.py files.uv run ruff check on changed example files and fix violations until it passes (respecting repository pyproject.toml under [tool.ruff]).git status to confirm expected moves and edits.main.py files include both top-level ft.SafeArea wrapping and the if __name__ == "__main__": ft.run(main) entrypoint.ft.SafeArea wrappers use expand=True only where needed for correct behavior and sizing; avoid forcing it by default.page.update() calls in in-scope examples (unless explicitly required by isolated-control or non-auto-update behavior).use_material3.pyproject.toml has a meaningful, example-specific [project].description (not generic or templated text)."save to file" when the example code supports file export/save behavior.__init__.py left behind once a touched control folder has been fully converted.main.py and that no stale doc includes remain for the touched examples.SafeArea, Column, Row, Container, etc.), keep content= or controls= as the last named argument in that control call.pyproject.toml under [tool.ruff] for all edits.rg --files <target_dir>rg -n "<old_path_or_module>" packages examplespython -m compileall <changed_main_files>uv run ruff check <changed_example_files>Report: