Skip to content
pubscout

rx_bloc

6.0.1, released 2 years ago by primeholding.com

A BLoC design pattern implementation using reactive streams.

WASM-ready
$ flutter pub add rx_bloc
Source repository

What it does

Helps implement the BLoC design pattern using reactive streams from RxDart. It separates business logic from the UI layer via event and state contracts, with support for zero-boilerplate generation.

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

Use it when

  • You want to implement the BLoC pattern using RxDart reactive streams
  • You need a clear separation of events, states, and business logic

Skip it when

  • You prefer simpler state management solutions like Provider
  • You do not want to use reactive streams or RxDart

Strengths

  • Strong decoupling of UI and business logic
  • Built-in result handling for loading and error states
  • Zero-boilerplate capabilities via code generation

Weaknesses

  • Requires familiarity with RxDart and reactive programming
  • Requires code generation setup for optimal usage

Setup

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

Requires adding build_runner and rx_bloc_generator to dev_dependencies and running the code generator.

@RxBloc()
class CounterBloc extends $CounterBloc {
  @override
  Stream<int> _mapToCountState() => _$incrementEvent.map((_) => 1);
}

Alternatives

Packages that do the same job and could replace rx_bloc.

  • bloc

    If you want the standard BLoC library implementation without relying heavily on RxDart.

  • riverpod

    If you prefer a compile-safe, provider-based state management approach instead of streams.

Works with

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