flutter-architecture

Flutter 四层组件化 + MVVM 项目架构规范。适用于 Flutter 项目开发、新模块创建、目录结构设计、代码评审、架构对齐。支持在项目中直接创建/搭建整套 MVVM+组件化目录结构。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "flutter-architecture" with this command: npx skills add PipeDog/flutter-architecture

Flutter 组件化 + MVVM 架构规范

核心架构

四层纵向依赖(严格单向):

app → business → component → foundation

业务模块内 MVVM

View (page/view) → ViewModel → Repository → Model

层级职责速查

层级职责
app主工程层:全局配置、路由、启动项、模块编排,无业务逻辑
business业务组件层:强业务实现,按模块拆分,模块间通过路由通信
component功能组件层:公司/团队通用能力(支付、分享、推送等),与业务有一定绑定
foundation基础组件层:与公司/项目无关的底层能力,强可移植性

业务模块目录结构

{module}/
├── page/           # 页面:xxx_page.dart → XxxPage
├── view/           # 视图:xxx_view.dart、xxx_navigation_bar.dart 等
├── view_model/
├── model/
└── repository/

Page / View 命名(强制)

  • page:文件 xxx_page.dart,类 XxxPage
  • view:常规视图 xxx_view.dartXxxView;功能型 xxx_navigation_bar.dartXxxNavigationBar
  • 严禁:禁止使用 widget 关键字

依赖规则(严禁违反)

  • 上层可依赖下层,下层不可依赖上层
  • 同级业务不互相 import,仅通过路由通信
  • 依赖链唯一:app → business → component → foundation

目录创建能力(Scaffold)

当用户要求创建目录结构搭建架构新建模块scaffold 时,在项目 lib/ 下直接创建以下结构:

全量创建(新项目或完整搭建):

  • lib/app/config/lib/app/pages/
  • lib/business/{module}/ 下每个模块含 page/view/view_model/model/repository/
  • lib/component/(可含 pay、share、push、update 等子目录)
  • lib/foundation/(network、image、router、db、utils、base 等)

增量创建(新增业务模块):

  • lib/business/ 下创建 {module_name}/page/view/view_model/model/repository/
  • 模块名使用小写下划线(如 home、user_profile、scenario_learning)

创建时按 references/architecture.md 中的完整目录结构执行,确保层级与命名符合规范。

完整规范

详细目录结构、各层说明、MVVM 职责、命名规范、代码示例、Code Review 标准见 references/architecture.md

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Research

Agent OS (Three Layer)

Provides a reusable AI agent OS template with separated identity, operations, and knowledge layers for modular intelligent system design.

Registry SourceRecently Updated
0119
Profile unavailable
General

Huo15 Doc Template

生成符合公司规范的正式Word文档模板,包含字体规范、公文格式页面设置、页眉(含LOGO)和页脚页码的标准排版规则。

Registry SourceRecently Updated
098
Profile unavailable
General

Official Writing 公文写作技能

党政机关公文写作技能 - 提供国家标准格式规范、各类公文模板、写作技巧

Registry SourceRecently Updated
065
Profile unavailable