SuperAPI AI 工具集

flutter-feature-based-clean-architecture

编程与开发

查看项目

更新于 10-15 22:13

技能介绍

用途:在 Flutter 项目中按功能模块组织整洁架构,适用于在 lib/features/ 下创建新功能时使用。

主要能力:每个功能位于 lib/features/ 下,分为三层。domain/ 存放实体、失败类型与仓库接口;data/ 存放 DTO、DataSource 与仓库实现;presentation/ 存放 BLoC/Cubit、页面与组件。依赖规则为 Presentation -> Domain <- Data,domain 层不得有外部依赖。跨领域逻辑放入 lib/shared/ 或 lib/core/。

使用方式:先创建功能目录(如 lib/features/promotions/),再定义 domain 层,随后实现 data 层,最后构建 presentation 层,并检查依赖方向。完整目录蓝图见 references/folder-structure.md,跨层依赖模板见 references/REFERENCE.md。

反模式:禁止跨功能导入 data 层,跨功能只导入 domain 类型;domain 层不得出现 UI 或 data 类;lib/features/ 保持扁平,不嵌套子功能目录;UI 不得直接调用其他功能的仓库,应通过 BLoC 或用例。

相关主题:layer-based-clean-architecture、retrofit-networking、go-router-navigation、bloc-state-management、dependency-injection。

限制:资料未提供具体安装命令、版本要求或完整代码示例,需参考上述引用文件。