AgentLint 实测验证 89/100基于 55 个 Dart / Flutter 开源仓库统计
Dart / Flutter CLAUDE.md & AGENTS.md 模板
flutter test 定向单测、dart analyze 严格模式与 Widget 测试规范,提炼自 Dart/Flutter 仓库。
# Dart / Flutter Project — Dart / Flutter Harness Flutter application verified with `dart analyze`, `dart format`, and targeted widget/unit tests. ## Commands - Fast single test: `flutter test test/unit/target_test.dart` - Full tests: `flutter test` - Analyze & format: `dart analyze --fatal-infos && dart format --output=none --set-exit-if-changed .` - Codegen: `dart run build_runner build --delete-conflicting-outputs` ## Rules - Don't hand-edit `*.g.dart` or `*.freezed.dart` files. Instead update the source model and re-run `build_runner`. Because manual edits get wiped on the next build. - Don't skip `dart analyze --fatal-infos` before committing. Because analyzer infos frequently catch unawaited futures and disposed controller leaks. - When modifying navigation or state providers, read `docs/state-architecture.md`. ## Continuity - Keep signing keys, `.env`, and `CLAUDE.local.md` out of git and record UI test evidence in `HANDOFF.md`.
Dart / Flutter 开源生态中最常采用的工程规则
基于 4,533 仓库研究中 55 个公开 Dart / Flutter 仓库的实测统计:
flutter框架
Flutter framework
66.7%30 个仓库
flutter-test测试
flutter test for testing
42.2%19 个仓库
provider代码规范
Provider for state management
37.8%17 个仓库
unit-tests测试
Write unit tests for all changes
37.8%17 个仓库
error-handling代码规范
Proper error handling with context
35.6%16 个仓库
ci-cd工具链
CI/CD pipeline must pass
28.9%13 个仓库
riverpod工具链
Riverpod for state management
28.9%13 个仓库
material-design代码规范
Material Design widgets
26.7%12 个仓库
必写验证命令(对应规则 W1 与 W7)
- 安装依赖
- flutter pub get
- 快速单测(秒级迭代)
- flutter test test/unit/target_test.dart
- 全量测试
- flutter test
- Lint 与静态检查
- dart analyze --fatal-infos && dart format --output=none --set-exit-if-changed .
- 生产构建
- flutter build web
Dart / Flutter 项目中 AI 代理常见踩坑
- 01AI 直接手改
.g.dart/.freezed.dart生成文件,而不是更新源模型后重跑build_runner。 - 02深层 Widget 树漏加
const构造函数导致帧率下降。