riverpod_generator
4.0.10, released 14 days ago by dash-overflow.net
Generates Riverpod providers from annotated functions using build_runner.
What it does
It reads functions annotated with @riverpod and creates matching provider classes automatically. The generated providers support hot‑reload and full Riverpod features without manual boilerplate.
AI-written summary of version 4.0.10, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want type‑safe Riverpod providers without writing boilerplate code
- You need multiple parameters or named arguments for providers
- You want stateful hot‑reload of providers during development
Skip it when
- You cannot add a build step or prefer pure runtime definitions
- Your project is tiny and the generator overhead isn’t justified
- You need providers that must be defined dynamically at runtime
Strengths
- Eliminates manual provider boilerplate
- Supports multiple and named parameters for families
- Enables stateful hot‑reload of individual providers
Weaknesses
- Adds a build_runner step and generated code to the project
- Debugging generated code can be less straightforward
- Only works for Dart/Flutter projects that can run code generation
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 11
Add riverpod_generator as a dev_dependency, ensure riverpod_annotation is in dependencies, run `dart run build_runner watch` or `build_runner build`. Optional build.yaml can customize provider name suffixes.
@riverpod
String label(Ref ref) => 'Hello world';
// generated: final labelProvider = Provider<String>((ref) => 'Hello world');Alternatives
Packages that do the same job and could replace riverpod_generator.
- mobx_codegen
Generates MobX store boilerplate from @observable, @computed and @action annotations.
85Compare - flutter_gen_runner
Generates strongly-typed Dart classes for Flutter assets, fonts, and colors to avoid string-based APIs.
87Compare - flutter_gen
A code generator for your assets, fonts, and colors to eliminate string-based APIs.
87Compare - drift_dev
Generates Dart database code from Drift table definitions as a dev‑dependency.
84Compare
Works with
Packages commonly used together with riverpod_generator: ones it builds on, ones built on it, and its own family.
- analyzerriverpod_generator depends on itPerforms static analysis of Dart code for tool integration and embedding.
- cryptoriverpod_generator depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- buildriverpod_generator depends on itPackage for authoring build_runner compatible code generators.
- build_configriverpod_generator depends on itFormat definition and support for parsing build.yaml configuration.
- source_genriverpod_generator depends on itSource code generation builders and utilities for the Dart build system.
- riverpod_annotationriverpod_generator depends on itAnnotations for riverpod_generator to enable code generation
- analyzer_bufferriverpod_generator depends on itHelper for code generators to write code with import prefixes and default values
- build_runnerUsed togetherA build system for Dart code generation and modular compilation.