flutter-best-practices

Applies Flutter architecture, feature structure, and Dart coding standards when writing or reviewing code.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/sohampawar1866/zeromile-go --skill flutter-best-practices-sohampawar1866
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flutter-best-practices
Source: https://github.com/sohampawar1866/zeromile-go/tree/main/.agents/skills/flutter-best-practices
Command: npx skills add https://github.com/sohampawar1866/zeromile-go --skill flutter-best-practices-sohampawar1866

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Flutter codebases drift into inconsistent architecture, scattered feature code, and untestable widgets as they grow. This Skill provides concrete standards for layering, feature organization, state management, and Dart coding style so code stays maintainable from small apps to multi-team monorepos. ## Core Features & Use Cases - Architecture guidance: Enforces unidirectional View → ViewModel → Repository → Service layering with no business logic in widgets and no BuildContext in business logic. - Feature-based structure: Organizes code by feature with union-type states, Cubits, presentation events, and provider-scoped dependency injection. - Enterprise scale patterns: Covers Melos monorepos, vertical domain packages, cross-domain events, navigation targets, localization boundaries, and Patrol E2E testing. - Use Case: When adding a new screen, the Skill walks you through defining the state union first, then the Cubit with constructor-injected dependencies, then the widgets, with unit tests for the logic before UI wiring. ## Quick Start Use the flutter-best-practices skill to review my Flutter feature for architecture and coding standard violations.

Frequently Asked Questions about flutter-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Flutter feature folder?

Group everything a feature needs under one directory: its cubit or bloc, entrypoint widget, and sub-widgets. Avoid top-level blocs/, widgets/, or models/ buckets that scatter a feature across the tree. Other features interact only with the entrypoint widget, never internals.

How should I manage state in Flutter with Cubit?

Model state as a sealed or union type (initial, inProgress, failure, ready) so every case is handled exhaustively, using freezed or Dart 3 sealed classes. Keep Cubits free of BuildContext, inject dependencies through the constructor, and emit one-off effects like snackbars as presentation events via bloc_presentation.

When should I add a repository or use case in Flutter?

Add a repository only when a feature needs caching, offline support, or merging multiple data sources; a Cubit calling a typed API client directly is fine otherwise. Add a use case only when logic merges multiple repositories, is genuinely complex, or is reused by several view models.

Should Flutter packages own their own localization?

Keep localization in the host app using gen-l10n with .arb files, and pass strings into reusable packages through constructor parameters. Package-owned ARB bundles only make sense for genuinely published packages with stable, independently translated copy.

What lint rules help enforce Flutter widget best practices?

The leancode_lint package bundles rules like use_padding, use_colored_box, and prefix_widgets_returning_slivers that automate widget guidance. Set strict lints at project start, since retrofitting them onto a mature codebase is far more expensive.