Your code stays safe
Three kinds of markers
Section titled “Three kinds of markers”Router & DI (wiring)
Section titled “Router & DI (wiring)”// <stackchain:routes>GoRoute(path: AppRoutes.home, ...),// </stackchain:routes>sync / feature / upgrade replace only the inside. State-only migrate also leaves code outside these markers alone.
Page UI (state-bound)
Section titled “Page UI (state-bound)”Widget build(BuildContext context) { // <stackchain:generated> return BlocProvider(/* … */); // </stackchain:generated>}Refreshed on migrate and feature --overwrite so pages match the new state API.
Your methods (presentation)
Section titled “Your methods (presentation)”// <stackchain:custom>Future<void> myExtraLogic() async { ... }// </stackchain:custom>Put custom methods here in Bloc / Cubit / Page / Controller classes. They survive feature, test, and migrate — including state swaps (e.g. Bloc → Cubit).
Generated test scaffolds
Section titled “Generated test scaffolds”// <stackchain:generated>// …scaffold assertions…// </stackchain:generated>Refresh keeps anything outside these markers. Permanent custom tests:
test/features/<feature>_custom_test.dart # never overwrittenWhat migrate rewrites entirely
Section titled “What migrate rewrites entirely”These app-shell files are regenerated for the target stack (not region-merged):
lib/bootstrap.dartlib/main.dart/main_*.dartlib/app/app.dart
Don’t put one-off business logic there.
Rules of thumb
Section titled “Rules of thumb”- Don’t edit inside
routes/core/features/generatedmarkers — they’ll be rewritten. - Do put logic in
// <stackchain:custom>or in your own files /*_custom_test.dart. - Use
--dry-runbeforemigrateor--overwrite. - Legacy files without markers get a
*.stackchain.bakbackup before replace.
Overwrite vs merge
Section titled “Overwrite vs merge”| Mode | Effect |
|---|---|
| Default | Soft-merge markers; skip unmarked customized files |
--overwrite / migrate presentation |
Refresh lib/ scaffolds; custom regions & *_custom_test stay |
Region merge (sync) |
Replace only marked interiors |
Domain / data layers stay yours unless you change architecture.