code-generation
Runs build_runner across core, data_source, and apps/main via the makefile after edits to freezed/injectable/retrofit/hive sources
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Runs build_runner across core, data_source, and apps/main via the makefile after edits to freezed/injectable/retrofit/hive sources
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Handles cross-feature BusEvent communication with EventBusManager in the Flutter base template
Implements BLoC state management using AppBlocBase, an abstract State hierarchy, and a freezed _StateData
Builds the data layer with Freezed DTOs, Retrofit clients, hive_ce local stores, and repositories wired through injectable
Reviews UI-layer changes — screens, blocs, widgets, routes — against the template's StateBase + AppBlocBase + fl_theme conventions
Adds and updates app strings through the CSV → ARB → generated localizations workflow
Scaffolds a new feature module under apps/main/lib/presentation/modules using the bundled module generator
| name | code-generation |
| description | Runs build_runner across core, data_source, and apps/main via the makefile after edits to freezed/injectable/retrofit/hive sources |
| license | MIT |
| compatibility | all |
| metadata | {"audience":"flutter-developers","framework":"flutter","pattern":"code-generation"} |
After editing any file annotated with @freezed, @JsonSerializable/@JsonKey, @Injectable/@LazySingleton/@Singleton/@module, @RestApi, @HiveType, or that declares a _StateData for a bloc.
The makefile is the canonical interface. It auto-detects fvm if present and falls back to the system Flutter SDK.
| Command | What it runs |
|---|---|
make gen_all | gen_core → gen_data_source → gen_main (full graph) |
make gen_main | build_runner build only inside apps/main/ |
make gen_core | build_runner build only inside core/ |
make gen_data_source | build_runner build only inside modules/data_source/ |
make gen | Interactive picker for the same targets |
make lang | Regenerates app_localizations_*.dart from localizations.csv |
make asset | Regenerates the asset accessor under each package |
make format | dart format . across the repo |
make pub_get | pub get across plugins, core, main |
When you don't know the scope of your change, run make gen_all. It's slower but never wrong.
| Pattern | Producer | Hand-edit? |
|---|---|---|
*.freezed.dart | freezed | Never |
*.g.dart | json_serializable, retrofit, hive_ce | Never |
*.config.dart | injectable | Never |
app_localizations*.dart | flutter intl tooling via make lang | Never |
All generated files are committed to source control — CI does not regenerate them.
dart run build_runner clean from inside the failing package, then re-run make gen_<scope>.part directive — every freezed/json/retrofit source needs the matching part 'foo.freezed.dart'; / part 'foo.g.dart';.sealed — freezed unions and the bloc _StateData require sealed class.@Default(...) — non-nullable fields without a default break codegen.--delete-conflicting-outputs; if you're invoking dart run build_runner directly, do the same.Useful while iterating on a single package:
cd apps/main
fvm dart run build_runner watch --delete-conflicting-outputs # or `dart run …` if no fvm
Stop with Ctrl-C. Don't leave it running in CI.
For a pre-commit/CI gate, run make gen_all and then assert that no generated artifacts changed:
make gen_all
git diff --exit-code -- '**/*.freezed.dart' '**/*.g.dart' '**/*.config.dart' \
'apps/main/lib/l10n/generated/**'
@freezed/@Injectable/@RestApi/@HiveType source, make gen_all (or the narrow target) was run.localizations.csv, make lang was run.dart run build_runner build without --delete-conflicting-outputs and stopping at the first conflict.*.freezed.dart to silence an analyzer warning — fix the source instead.make gen_main does not touch core/ or modules/data_source/. When core types change, run make gen_all.