Convert an imperative Flet Python app in which controls are mutated and then page.update is called to declarative style using flet.component, flet.observable and state hooks.
64
77%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.agents/skills/imperative-to-declarative-flet/SKILL.mdPort an existing imperative Flet app to “components mode” with @ft.component, hooks, and (optionally) @ft.observable models.
page.render(App) (components mode).page.update() for normal UI updates.@ft.observable for nested app data you mutate in place (boards/lists/cards, drag+drop reorder).ft.use_state for local ephemeral UI state (hover flags, input text, dialog selection).Control/component objects in state; store ids/enums and create controls during render.trolli → trolli-declarative-*).assets/ with the new folder.@ft.component def App(): ....ft.run(lambda page: page.render(App), assets_dir=...)main(page) function before page.render(App), orft.on_mounted(...) (works, but ordering can be less obvious).Appapp.route: str as source of truth.route_change(e) to normalize/redirect/validate routes and set app.routematch app.route (or a derived active_screen) to pick contentroute_change mutates route state; App() render chooses UI based on that state.src/components/*.py.page.update() usageIf a dialog mutates existing controls and calls page.update(), convert it to:
@ft.component dialog content with ft.use_state for error, selected_color, etc.page.show_dialog(ft.AlertDialog(content=DialogContent(...)))assets_dir derived from __file__.flet run, be aware it can set FLET_ASSETS_DIR and override assets_dir=.page.fonts = {"Pacifico": "Pacifico-Regular.ttf"}font_family="Pacifico".Event[Sub] ≠ Event[Base]):
on_click is declared on Button, annotate e as ft.Event[ft.Button] (or use def handler(): ...).TemplateRoute params are dynamic:
raw = getattr(troute, "id", None) then isinstance(raw, str) before int(raw).controls=[*[...], ...] can confuse type checkers with components:
db0df8e
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.