stacked_generator
2.0.4, released 5 months ago by filledstacks.com
Generates routing and dependency‑injection boilerplate for Stacked apps.
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 buildAlternatives
Packages that do the same job and could replace stacked_generator.
- rx_bloc_generator
Code generator for rx_bloc that eliminates boilerplate code.
55Compare
Works with
Packages commonly used together with stacked_generator: ones it builds on, ones built on it, and its own family.
- analyzerstacked_generator depends on itPerforms static analysis of Dart code for tool integration and embedding.
- dart_stylestacked_generator depends on itProvides an API and CLI to format Dart source code automatically.
- json_annotationstacked_generator depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- code_builderstacked_generator depends on itA fluent, builder-based library for generating valid Dart code programmatically.
- buildstacked_generator depends on itPackage for authoring build_runner compatible code generators.
- source_genstacked_generator depends on itSource code generation builders and utilities for the Dart build system.
- freezed_annotationstacked_generator depends on itAnnotations for the freezed code-generator.
- loggerstacked_generator depends on itAn extensible logger for printing formatted logs with levels, custom filters, and printers.