跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 flutter-apply-architecture-best-practices

Flutter Apply Architecture Best Practices

使用推荐分层方法(UI, Logic, Data)构建出一款Fluster应用程序. 在构建新工程或重构可缩放性时使用.

40356 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

使用推荐分层方法(UI、Logic、Data)构建一个小蝶应用程序

何时用

为可扩展性构建新项目或重构

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Architecting Flutter Applications、Contents、Architectural Layers、UI Layer (Presentation)、Data Layer、Logic Layer (Domain - Optional)。 其中含规范建议的小节:分步指令、输入输出示例。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

Architects a Flutter application using the recommended layered approach (UI, Logic, Data). Use when structuring a new project or refactoring for scalability.

Architecting Flutter ApplicationsContentsArchitectural LayersUI Layer (Presentation)Data LayerLogic Layer (Domain - Optional)Project StructureWorkflow: Implementing a New FeatureTask ProgressExamplesData Layer: Service and RepositoryUI Layer: ViewModel and View

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
flutter-apply-architecture-best-practices
description
Architects a Flutter application using the recommended layered approach (UI, Logic, Data). Use when structuring a new project or refactoring for scalability.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「flutter-apply-architecture-best-practices」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-4cb95abd6e9a9f90-Flutter-%E5%BA%94%E7%94%A8%E6%9E%B6%E6%9E%84-%E6%9C%80%E4%BD%B3%E5%81%9A%E6%B3%95.html
请存为 .cursor/skills/flutter-apply-architecture-best-practices/SKILL.md 或 .claude/skills/flutter-apply-architecture-best-practices/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/flutter/agent-plugins' --list

npx skills add 'https://github.com/flutter/agent-plugins' --skill 'flutter-apply-architecture-best-practices'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: flutter-apply-architecture-best-practices description: Architects a Flutter application using the recommended layered approach (UI, Logic, Data). Use when structuring a new project or refactoring for scalability. metadata: model: models/gemini-3.1-pro-preview last_modified: Tue, 21 Apr 2026 20:11:20 GMT --- # Architecting Flutter Applications ## Contents - [Architectural Layers](#architectural-layers) - [Project Structure](#project-structure) - [Workflow: Implementing a New Feature](#workflow-implementing-a-new-feature) - [Examples](#examples) ## Architectural Layers Enforce strict Separation of Concerns by dividing the application into distinct layers. Never mix UI rendering with business logic or data fetching. ### UI Layer (Presentation) Implement the MVVM (Model-View-ViewModel) pattern to manage UI state and logic. * **Views:** Write reusable, lean widgets. Restrict logic in Views to UI-specific operations (e.g., animations, layout constraints, simple routing). Pass all required data from the ViewModel. * **ViewModels:** Manage UI state and handle user interactions. Extend `ChangeNotifier` (or use `Listenable`) to expose state. Expose immutable state snapshots to the View. Inject Repositories into ViewModels via the constructor. ### Data Layer Implement the Repository pattern to isolate data access logic and create a single source of truth. * **Services:** Create stateless classes to wrap external APIs (HTTP clients, local databases, platform plugins). Return raw API models or `Result` wrappers. * **Repositories:** Consume one or more Services. Transform raw API models into clean Domain Models. Handle caching, offline synchronization, and retry logic. Expose Domain Models to ViewModels. ### Logic Layer (Domain - Optional) * **Use Cases:** Implement this layer only if the application contains complex business logic that clutters the ViewModel, or if logic must be reused across multiple ViewModels. Extract this logic into dedicated Use Case (interactor) classes that sit between ViewModels and Repositories. ## Project Structure Organize the codebase using a hybrid approach: group UI components by feature, and group Data/Domain components by type. ```text lib/ ├── data/ │ ├── models/ # API models │ ├── repositories/ # Repository implementations │ └── services/ # API clients, local storage wrappers ├── domain/ │ ├── models/ # Clean domain models │ └── use_cases/ # Optional business logic classes └── ui/ ├── core/ # Shared widgets, themes, typography └── features/ └── [feature_name]/ ├── view_models/ └── views/ ``` ## Workflow: Implementing a New Feature Follow this sequential workflow when adding a new feature to the application. Copy the checklist to track progress. ### Task Progress - [ ] **Step 1: Define Domain Models.** Create immutable data classes for the feature using `freezed` or `built_value`. - [ ] **Step 2: Implement Services.** Create or update Service classes to handle external API communication. - [ ] **Step 3: Implement Repositories.** Create the Repository to consume Services and return Domain Models. - [ ] **Step 4: Apply Conditional Logic (Domain Layer).** - *If the feature requires complex data transformation or cross-repository logic:* Create a Use Case class. - *If the feature is a simple CRUD operation:* Skip to Step 5. - [ ] **Step 5: Implement the ViewModel.** Create the ViewModel extending `ChangeNotifier`. Inject required Repositories/Use Cases. Expose immutable state and command methods. - [ ] **Step 6: Implement the View.** Create the UI widget. Use `ListenableBuilder` or `AnimatedBuilder` to listen to ViewModel changes. - [ ] **Step 7: Inject Dependencies.** Register the new Service, Repository, and ViewModel in the dependency injection container (e.g., `provider` or `get_it`). - [ ] **Step 8: Run Validator.** Execute unit tests for the ViewModel and Repository. - *Feedback Loop:* Run tests -> Review failures -> Fix logic -> Re-run until passing. ## Examples ### Data Layer: Service and Repository ```dart // 1. Service (Raw API interaction) class ApiClient { Future fetchUser(String id) async { // HTTP GET implementation... } } // 2. Repository (Single source of truth, returns Domain Model) class UserRepository { UserRepository({required ApiClient apiClient}) : _apiClient = apiClient; final ApiClient _apiClient; User? _cachedUser; Future getUser(String id) async { if (_cachedUser != null) return _cachedUser!; final apiModel = await _apiClient.fetchUser(id); _cachedUser = User(id: apiModel.id, name: apiModel.fullName); // Transform to Domain Model return _cachedUser!; } } ``` ### UI Layer: ViewModel and View ```dart // 3. ViewModel (State management and presentation logic) class ProfileViewModel extends ChangeNotifier { ProfileViewModel({required UserRepository userRepository}) : _userRepository = userRepository; final UserRepository _userRepository; User? _user; User? get user => _user; bool _isLoading = false; bool get isLoading => _isLoading; Future loadProfile(String id) async { _isLoading = true; notifyListeners(); try { _user = await _userRepository.getUser(id); } finally { _isLoading = false; notifyListeners(); } } } // 4. View (Dumb UI component) class ProfileView extends StatelessWidget { const ProfileView({super.key, required this.viewModel}); final ProfileViewModel viewModel; @override Widget build(BuildContext context) { return ListenableBuilder( listenable: viewModel, builder: (context, _) { if (viewModel.isLoading) { return const Center(child: CircularProgressIndicator()); } final user = viewModel.user; if (user == null) { return const Center(child: Text('User not found')); } return Column( children: [ Text(user.name), ElevatedButton( onPressed: () => viewModel.loadProfile(user.id), child: const Text('Refresh'), ), ], ); }, ); } } ```

相关技能

Agent 工作流

Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…