flutter-widget-architecture

Featured

Use when building Flutter screens - compose small stateless widgets, keep layout declarative, separate presentation from business logic, and use the theme not hardcoded styles

AI & Automation 91 stars 13 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 89/100

Stars 20%
65
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Flutter Widget Architecture ## Overview Flutter UI is a tree of widgets. The quality difference is in decomposition: small, focused, mostly-stateless widgets that read like the UI they render, with business logic pushed out of the widget tree. **Core principle:** Widgets describe what the UI looks like given state. They do not fetch data, hold business rules, or talk to the network — that lives in state/services (see flutter-state-management). ## Rules - **Prefer `StatelessWidget`.** Reach for `StatefulWidget` only for truly local, ephemeral UI state (an animation controller, a text field's focus). App/business state lives in your state management layer. - **Small widgets over deep `build` methods.** A `build` longer than ~40 lines or nested 5+ deep is a set of extract-widget opportunities. Extract named widgets, not `Widget _buildX()` helper methods (named widgets get their own rebuild scope and are testable). - **`const` constructors everywhere possible** — a `const` widget subtree is skipped on rebuild. This is the cheapest performance win in Flutter. - **Theme, not hardcoded styles.** Colors, text styles, spacing come from `Theme.of(context)` / a design-token file — never scattered `Color(0xFF...)` and magic paddings. This is the Flutter equivalent of "no custom CSS." - **Keys** only when you need identity across rebuilds (reorderable lists) — don't sprinkle them. ## Worked Example ```dart // ❌ one giant build, hardcoded style, logic in the widget Widget build(Bu...

Details

Author
makifbaysal
Repository
makifbaysal/tasktrooper
Created
1 weeks ago
Last Updated
today
Language
Go
License
Apache-2.0

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Listed

widget-composition

Enforces Flutter widget composition — extract named const Widget classes never `Widget _buildX()` methods, lean build() (no I/O/formatting/domain math, precompute in the ViewModel), dumb Views that watch one Notifier and route intents via ref.read, StatelessWidget by default with every controller disposed, lazy `.builder` lists, cheapest-widget choices (SizedBox/ColoredBox/Align over Container), a strict key policy (ValueKey for reorderable lists, never GlobalKey), gesture→visible-focusable-fallback wiring, plus structural layout — full-bleed background vs SafeArea content, computed cell sizing, the GridView cross/main-axis spacing trap, EdgeInsetsDirectional, and resizeToAvoidBottomInset/IME handling. Use when building or refactoring any screen or widget, splitting a large build() into components, writing GridView/ListView/LayoutBuilder/SafeArea/Scaffold, wiring onTap/onLongPress/Draggable, choosing a key or data class, or reviewing widget code in a diff.

0 Updated 1 months ago
zakariaf
Web & Frontend Listed

flutter-ui-patterns

Build and refactor Flutter widgets, forms with stale-safe asynchronous validation and duplicate-submit handling, widget previews, component APIs, and UI state boundaries. Use alone for form behavior over existing services; add networking or concurrency only when their infrastructure changes, and route visual polish, responsive layout, navigation, animation, and performance to their specialists.

7 Updated 1 weeks ago
thiennc-tesoglobal
Data & Documents Listed

flutter-architecture

Current (2026) Flutter app architecture from the Flutter team's official guide, Very Good Ventures and LeanCode - UI layer (View + ViewModel/Cubit/Notifier) and data layer (Repository + Service), feature folders, dependency injection, Result/Command patterns, networking and JSON models, go_router, monorepos with pub workspaces, day-one project setup, scaling teams, legacy refactoring. Use this whenever creating a new Flutter project or feature, deciding folder structure, adding a repository/API/service layer, choosing packages, reviewing Flutter code for maintainability, or scaling a Flutter team - even if the user only asks "where should this file go".

0 Updated yesterday
abugeek