Skip to content
pubscout

bloc_effects

2.1.0, released 4 months ago by darttech.dev

SingleLiveEvent pattern implementation for BLoC and Cubit to dispatch transient UI effects.

WASM-ready
$ flutter pub add bloc_effects
Source repository

What it does

Adds UI effects (such as bottom sheets, navigation, and dialogs) to the BLoC state management pattern using mixins like `Effects` or classes like `CubitWithEffects`. Provides widgets like `BlocEffectListener` and `BlocEffectConsumer` to listen and react to these transient events.

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

Use it when

  • You are using the bloc package and need to trigger one-time UI actions like showing dialogs or navigation.
  • You want to separate transient event emission from your persistent BLoC state.

Skip it when

  • You are not using the bloc or flutter_bloc packages.
  • State persistence across configuration changes is required for your UI events.

Strengths

  • Seamless integration with flutter_bloc.
  • Prevents UI effects from being re-emitted on widget rebuilds or configuration changes.

Weaknesses

  • Tied directly to the ecosystem of package:bloc.
  • Transient events are discarded if there are no active listeners.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1
class CounterCubit extends Cubit<int> with Effects<UiEffect> {
  CounterCubit() : super(0);
  void onButtonPressed() => emitEffect(ShowBottomSheet(counterValue: state));
}

Alternatives

Packages that do the same job and could replace bloc_effects.

  • bloc

    Provides the foundational BLoC state management architecture without dedicated single-live-event effect abstractions.

Works with

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