Migration guide
Adopting stackchain in an existing app
Section titled “Adopting stackchain in an existing app”- Ensure the repo is a Flutter app with a normal
pubspec.yaml. dart pub add --dev stackchain- Write
stackchain.yamlmatching your intended target stack (or a preset). dart run stackchain init --dry-runtheninit(use--overwritecarefully).- Resolve conflicts manually — stackchain skips existing files by default.
- Move hand-written features into the generated layout gradually; use
featurefor new slices.
Evolving stack within stackchain
Section titled “Evolving stack within stackchain”# Previewdart run stackchain migrate --state bloc --dry-run
# Apply (rewrites bootstrap, presentation, DI, tests, pubspec)dart run stackchain migrate --state bloc
# Routing / DIdart run stackchain migrate --routing go_router --di get_it
# Apply a whole presetdart run stackchain migrate --preset production_riverpodWhat migrate changes
Section titled “What migrate changes”- Refreshes app shell (
bootstrap.dart, mains,app.dart) for the target stack - Regenerates presentation / state / bindings (and fuller tree on architecture change)
- Refreshes feature tests for the new state management
- Leaves domain & data intact (unless architecture itself changes)
- Optionally deletes old generated files/packages (unless
--keep-old) - Rewrites YAML, syncs router/DI, runs gate
Example: Riverpod → Bloc
Section titled “Example: Riverpod → Bloc”Before migrate, bootstrap may look like:
runApp(const ProviderScope(child: App()));After migrate --state bloc:
runApp(const App());Riverpod packages are dropped from pubspec.yaml, Bloc presentation files are generated, and DI registers Bloc + datasource/repository/use case for each feature.
See migrate for the full option list.
Feature lifecycle
Section titled “Feature lifecycle”dart run stackchain feature authdart run stackchain rename profile accountdart run stackchain remove authFrom counter app
Section titled “From counter app”init replaces the stock counter entrypoint with configureDependencies + App via bootstrap.dart.