plugins/languages/flutter/skills/core/SKILL.md
Flutter/Dart 核心开发规范 — Dart 3.6+ 特性 (Records/Patterns/Sealed/Class modifiers/Extension types)、Flutter 3.27+ 工具链、命名约定、Clean Architecture 项目结构、dart analyze/format/fix。Use when 创建 Flutter 项目、编写 Dart 代码、审查/重构 Dart 代码、配置 pubspec.yaml/analysis_options.yaml、讨论项目分层。Also triggers on "Dart 代码风格"、"Flutter 项目结构"、"analysis_options"、"pubspec 配置"、"Clean Architecture flutter"。
npx skillsauth add lazygophers/ccplugin flutter-coreInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Flutter 开发追求 Dart 3 类型安全 + 平台自适应 UI + 可测试 Clean Architecture。
@riverpod 代码生成、AsyncNotifierpresentation / domain / datago_router 14+Theme/ColorScheme 取)AnimationController / StreamSubscription / Timer)Navigator.push 命令式路由 (用 go_router).dart 文件 > 600 行 (推荐 200~400)very_good_analysis 或 flutter_lints// 1. Records
(String, int) getInfo() => ('Alice', 30);
final (name, age) = getInfo();
// 2. Patterns + switch expression
String describe(Object o) => switch (o) {
int n when n > 0 => 'positive',
int() => 'non-positive',
String s => 'string: $s',
_ => 'unknown',
};
// 3. Sealed classes
sealed class Result<T> { const Result(); }
final class Success<T> extends Result<T> {
const Success(this.data);
final T data;
}
final class Failure<T> extends Result<T> {
const Failure(this.error);
final Object error;
}
// 4. Class modifiers
final class AppConfig {} // 不可继承
interface class Serializable {} // 仅可 implement
base class BaseRepo {} // 仅可 extend
// 5. Extension types (零成本抽象)
extension type UserId(String value) implements String {}
class UserProfileCard {} // 类型 PascalCase
final userName = 'John'; // 变量/函数 camelCase
const defaultPadding = 16.0; // 常量 camelCase (Dart 风格)
class _InternalWidget {} // 私有 _ 前缀
// 文件: snake_case.dart
final userProvider = ...; // Provider: 驼峰 + Provider 后缀
lib/
core/ # 基础设施
theme/ router/ constants/ extensions/ utils/
features/ # 按功能划分
auth/
data/ # Repository 实现 / DataSource / DTO
domain/ # Entity / UseCase / Repository 接口
presentation/ # Widget / Controller (ViewModel)
home/
shared/ # 共享 widget/model
test/ # 镜像 lib/features
integration_test/ # 端到端
flutter create --org com.example --platforms android,ios,web my_app
flutter pub add flutter_riverpod riverpod_annotation go_router
flutter pub add dev:riverpod_generator dev:build_runner dev:riverpod_lint dev:custom_lint dev:very_good_analysis
dart run build_runner build --delete-conflicting-outputs
dart analyze && dart format . && dart fix --apply
| AI 借口 | 实际检查 | 严重度 | | --- | --- | --- | | "if-else 就够了" | 是否用 sealed + switch expression? | 中 | | "Provider 够用" | Provider 已停维,迁 Riverpod | 高 | | "GetX 开发快" | GetX 技术债,迁 Riverpod/Bloc | 高 | | "直接写颜色值" | 是否从 Theme/ColorScheme 取? | 高 | | "Navigator.push 更直接" | 是否用 go_router? | 中 | | "不需要 class modifier" | 是否用 final/sealed/base? | 中 |
useMaterial3: true) 或 Cupertino 一致使用@riverpod 代码生成go_router 14+ 声明式路由const Widget 最大化dart analyze 零警告 / very_good_analysis 通过Skills(flutter:state) — Riverpod 3 / Bloc 8Skills(flutter:ui) — Material 3 / Cupertino / ImpellerSkills(flutter:android) / Skills(flutter:ios) / Skills(flutter:web)tools
UI/UX 与布局设计——做界面布局/结构/导航/组件/交互的设计决策。触发:做UI/UX/布局/排版/导航/组件/交互/栅格/响应式/图表选型/字体配对。按媒介路由 HTML/Web、原生 App(iOS/Android/桌面)、CLI、TUI。需后端动态系统不适用;配色/主题/色板走姊妹 skill design-color。
tools
主题与配色设计——做颜色搭配/调色板/主题/品牌色阶/暗模式的设计决策。触发:选配色/调色/主题/色板/品牌色/暗模式/对比度/色盲/UI风格。按媒介路由 HTML/Web(CSS变量)、原生App(平台token)、CLI(ANSI)、TUI(真彩/256/16降级)。保证可访问性(对比度/色盲安全)。需后端动态系统不适用;UI/UX 布局/组件/交互走姊妹 skill design-uiux。
tools
跨任意组件(plugin/skill/agent/command)的验证驱动优化循环纪律 skill。当用户要优化某个已有组件却无明确方向、或要防止改了反而更差(自评乐观偏差 / 多维同改归因失效 / 为凑分加废话膨胀)、或要把一套通用「评分→单变量改→改后验证严格更好才留否则回滚→触顶停」的纪律套到任意组件上时使用。管优化过程本身的纪律(validation gate / ratchet / 独立验证 / 触顶停),不评单组件深度(交 skill-dev),不查插件接线(交 plugin-dev)。仅手动 /optimize-any 触发。
data-ai
两层规则记忆 (基于 .skein/spec)。planning 时 recall 召回相关规则、task finish 后 sediment 沉淀学习 + prune 自动精简过期/重复/断链规则。core 常驻硬规 + recall 按需召回, 经判定门自动写盘 (不逐次问用户)。产出 .skein/spec 下 core/recall 规则文件 + index。另支持空仓 bootstrap 播种规则基线、记忆大面积失效 (大重构/换栈) 时 reconstruct 可逆归档后按项目类型分型重建、maintain 手动体检 (超预算/stale/断链/重复/废弃, --apply 自动修复)、auto-fix (Stop hook 写 .pending-fix 标记 → main 派 skein-specer bg 跑 maintain --apply 全自动修, 断链只报告)。