Skip to content
pubscout

stacked_generator

2.0.4, released 5 months ago by filledstacks.com

Generates routing and dependency‑injection boilerplate for Stacked apps.

$ flutter pub add stacked_generator
Source repository

What it does

The package reads a StackedApp annotation and creates the necessary route definitions and service registration code. It reduces manual setup of navigation and DI in Stacked projects. The generated code works with the Stacked framework version 1.9.0+.

AI-written summary of version 2.0.4, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to scaffold Stacked applications quickly without writing repetitive routing/DI code
  • You are already using the Stacked architecture and need compile‑time generation of routes and services

Skip it when

  • You are not using Stacked or prefer manual setup
  • You need runtime‑only DI without code generation

Strengths

  • Eliminates boilerplate for Stacked routing and DI
  • Integrates directly with Stacked’s annotation system
  • Keeps generated code type‑safe and up‑to‑date

Weaknesses

  • Tied to the Stacked framework, not useful for other architectures
  • Requires build_runner to run the generator

Setup

Kind
Pure Dart
Effort
Medium
Code generation
Yes (build_runner)
Direct dependencies
13

Add stacked_generator to dev_dependencies, run `flutter pub run build_runner build` after adding a StackedApp annotation.

import 'package:stacked/stacked.dart';
import 'package:stacked_generator/stacked_generator.dart';

@StackedApp(
  routes: [MaterialRoute(page: HomeView)],
  dependencies: [LazySingleton(classType: HomeService)],
)
class AppSetup {}

// Run: flutter pub run build_runner build

Alternatives

Packages that do the same job and could replace stacked_generator.

Works with

Packages commonly used together with stacked_generator: ones it builds on, ones built on it, and its own family.