Token导航 LogoToken导航TokenDH.com
前端设计external-servicegithub未标认证来源可访问许可证需确认审计通过

flutter-architectureFlutter 架构

Agent Skill

flutter-architecture 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 Codex、Claude、Cursor、Gemini CLI 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

27,192

周安装

1,133

GitHub Stars

1,328

下载量

8,536
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:flutter-architecture(Flutter 架构)
来源仓库:https://github.com/flutter/skills
仓库路径:skills/flutter-architecture
安装命令:
npx skills add https://github.com/flutter/skills --skill flutter-architecture
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/flutter/skills --skill flutter-architecture

简介

Flutter 应用程序的 MVVM 架构,具有单向数据流和严格的层分离。

  • 实现三层架构:数据层(服务和存储库)、领域层(复杂逻辑的用例)和 UI 层(视图模型和视图)
  • 使用提供商
  • 用于依赖注入和 ListenableBuilder
  • 通过用户交互的命令模式进行反应式 UI 更新
  • 强制单向数据流:数据从存储库向下流动到视图模型,再到视图;事件通过命令向上流动
  • 包括决策逻辑,用于根据数据源类型和业务逻辑复杂性确定何时创建服务、存储库和域层
  • 需要不可变的域模型、无状态服务和显式结果
  • 用于跨所有层进行错误处理的对象

SKILL.md

Flutter App Architecture Implementation

Goal

Implements a scalable, maintainable Flutter application architecture using the MVVM pattern, unidirectional data flow, and strict separation of concerns across UI, Domain, and Data layers. Assumes a standard Flutter environment utilizing provider for dependency injection and ListenableBuilder for reactive UI updates.

Decision Logic

Before implementing a feature, evaluate the architectural requirements using the following logic:

  1. Data Source:

- If interacting with an external API -> Create a Remote Service. - If interacting with local storage (SQL/Key-Value) -> Create a Local Service.

  1. Business Logic Complexity:

- If the feature requires merging data from multiple repositories or contains highly complex, reusable logic -> Implement a Domain Layer (UseCases). - If the feature is standard CRUD or simple data presentation -> Skip the Domain Layer; the ViewModel communicates directly with the Repository.

Instructions

  1. Analyze Feature Requirements Evaluate the requested feature to determine the necessary data models, services, and UI state. STOP AND ASK THE USER: "Please provide the specific data models, API endpoints, or local storage requirements for this feature, and confirm if complex business logic requires a dedicated Domain (UseCase) layer."
  2. Implement the Data Layer: Services Create a stateless service class to wrap the external API or local storage. This class must not contain business logic or state. class SharedPreferencesService {static const String _kDarkMode = 'darkMode'; Future<void> setDarkMode(bool value) async {final prefs = await SharedPreferences.getInstance(); await prefs.setBool(_kDarkMode, value);} Future<bool> isDarkMode() async {final prefs = await SharedPreferences.getInstance(); return prefs.getBool(_kDarkMode)?? false;}}
  3. Implement the Data Layer: Repositories Create a repository to act as the single source of truth. The repository consumes the service, handles errors using Result objects, and exposes domain models or streams. class ThemeRepository {ThemeRepository(this._service); final _darkModeController = StreamController<bool>.broadcast(); final SharedPreferencesService _service; Future<Result<bool>> isDarkMode() async {try {final value = await _service.isDarkMode(); return Result.ok(value);} on Exception catch (e) {return Result.error(e);}} Future<Result<void>> setDarkMode(bool value) async {try {await _service.setDarkMode(value); _darkModeController.add(value); return Result.ok(null);} on Exception catch (e) {return Result.error(e);}} Stream<bool> observeDarkMode() => _darkModeController.stream;}
  4. Implement the UI Layer: ViewModels Create a ChangeNotifier to manage UI state. Use the Command pattern to handle user interactions and asynchronous repository calls. class ThemeSwitchViewModel extends ChangeNotifier {ThemeSwitchViewModel(this._themeRepository) {load = Command0(_load)..execute(); toggle = Command0(_toggle);} final ThemeRepository _themeRepository; bool _isDarkMode = false; bool get isDarkMode => _isDarkMode; late final Command0<void> load; late final Command0<void> toggle; Future<Result<void>> _load() async {final result = await _themeRepository.isDarkMode(); if (result is Ok<bool>) {_isDarkMode = result.value;} notifyListeners(); return result;} Future<Result<void>> _toggle() async {_isDarkMode =!_isDarkMode; final result = await _themeRepository.setDarkMode(_isDarkMode); notifyListeners(); return result;}}
  5. Implement the UI Layer: Views Create a StatelessWidget that observes the ViewModel using ListenableBuilder. The View must contain zero business logic. class ThemeSwitch extends StatelessWidget {const ThemeSwitch({super.key, required this.viewmodel}); final ThemeSwitchViewModel viewmodel; @override Widget build(BuildContext context) {return Padding(padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Row(children: [const Text('Dark Mode'), ListenableBuilder(listenable: viewmodel, builder: (context, _) {return Switch(value: viewmodel.isDarkMode, onChanged: (_) {viewmodel.toggle.execute();},);},),],),);}}
  6. Wire Dependencies Inject the dependencies at the application or route level using constructor injection or a dependency injection framework like provider. void main() {runApp(MainApp(themeRepository: ThemeRepository(SharedPreferencesService()),),);}
  7. Validate and Fix Review the generated implementation against the constraints. Ensure that data flows strictly downwards (Repository -> ViewModel -> View) and events flow strictly upwards (View -> ViewModel -> Repository). If a View contains data mutation logic, extract it to the ViewModel. If a ViewModel directly accesses an API, extract it to a Service and route it through a Repository.

Constraints

  • No Logic in Views: Views must only contain layout logic, simple conditional rendering based on ViewModel state, and routing.
  • Unidirectional Data Flow: Data must only flow from the Data Layer to the UI Layer. UI events must trigger ViewModel commands.
  • Single Source of Truth: Repositories are the only classes permitted to mutate application data.
  • Service Isolation: ViewModels must never interact directly with Services. They must communicate exclusively through Repositories (or UseCases).
  • Stateless Services: Service classes must not hold any state. Their sole responsibility is wrapping external APIs or local storage mechanisms.
  • Immutable Models: Domain models passed from Repositories to ViewModels must be immutable.
  • Error Handling: Repositories must catch exceptions from Services and return explicit Result (Ok/Error) objects to the ViewModels.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.75%
按下载量换算3,052

Claude

31.13%
按下载量换算2,657

Cursor

19.83%
按下载量换算1,693

Gemini CLI

9.87%
按下载量换算843

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills