Skip to content
pubscout

rx_bloc_generator

9.0.0, released 11 months ago by primeholding.com

Code generator for rx_bloc that eliminates boilerplate code.

$ flutter pub add rx_bloc_generator
Source repository

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.

Works with

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