rx_bloc_generator
9.0.0, released 11 months ago by primeholding.com
Code generator for rx_bloc that eliminates boilerplate code.
What it does
Generates zero-boilerplate implementations for rx_bloc classes by analyzing event and state definitions. It automatically creates subjects, inputs, events, and dispose methods based on custom annotations.
AI-written summary of version 9.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are building an app using the rx_bloc state management pattern.
- You want to remove repetitive boilerplate code for handling bloc inputs, outputs, and disposal.
Skip it when
- you are not using the rx_bloc package for state management.
- You prefer writing your BLoC or stream boilerplate manually without a code generator.
Strengths
- Significantly reduces boilerplate for rx_bloc implementations.
- Supports event seeding, custom event types, and custom states.
- Integrates seamlessly with build_runner.
Weaknesses
- Requires running build_runner to generate files.
- Strict adherence to naming conventions and abstract class structures is required.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 8
Add rx_bloc_generator and build_runner to dev_dependencies and run build_runner.
abstract class NewsBlocEvents {
void fetch();
}
abstract class NewsBlocStates {
Stream<List<News>> get news;
}
@RxBloc()
class NewsBloc extends $NewsBloc {
@override
Stream<List<News>> _mapToNewsState() => _$fetchEvent.switchMap((_) => ...);
}Alternatives
Packages that do the same job and could replace rx_bloc_generator.
- json_serializable
Automatically generate code for converting Dart classes to and from JSON.
94Compare - pigeon
Type-safe code generator for communication between Flutter and host platforms.
90Compare - copy_with_extension
Annotation for generating copyWith extensions code using copy_with_extension_gen.
87Compare - widgetbook_annotation
Annotations for widgetbook_generator to build Flutter widgets in isolation.
80Compare
Works with
Packages commonly used together with rx_bloc_generator: ones it builds on, ones built on it, and its own family.
- analyzerrx_bloc_generator depends on itPerforms static analysis of Dart code for tool integration and embedding.
- dart_stylerx_bloc_generator depends on itProvides an API and CLI to format Dart source code automatically.
- code_builderrx_bloc_generator depends on itA fluent, builder-based library for generating valid Dart code programmatically.
- loggingrx_bloc_generator depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- buildrx_bloc_generator depends on itPackage for authoring build_runner compatible code generators.
- source_genrx_bloc_generator depends on itSource code generation builders and utilities for the Dart build system.
- rx_blocrx_bloc_generator depends on itA BLoC design pattern implementation using reactive streams.
- build_runnerUsed togetherA build system for Dart code generation and modular compilation.