Skip to content
pubscout

side_effect_bloc

1.0.0, released 5 years ago by georgeci.com

Extended bloc with a separate stream for one-time side effects.

WASM-ready
$ flutter pub add side_effect_bloc
Source repository

What it does

Extends the standard bloc pattern to support a secondary stream specifically for side effects that should be consumed only once, such as navigation or showing snackbars. It provides mixins and base classes to easily emit and listen to side effects separately from the UI state.

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

Use it when

  • You need to handle one-off events like navigation or snackbars cleanly in a BLoC architecture.
  • You want to avoid state-retrigger bugs when rebuilding widgets after a one-time event occurs.

Skip it when

  • You are not using the bloc or flutter_bloc packages.
  • Your architecture already handles side effects through regular events or other state management approaches.

Strengths

  • Clean separation of state changes from one-time side effects like navigation and toasts.
  • Provides both a mixin approach for existing blocs and a base class for new ones.
  • Includes convenient listener widgets for Flutter.

Weaknesses

  • Adds an extra conceptual layer on top of standard BLoC.
  • Limited documentation outside of basic usage examples.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
3

Requires existing bloc and flutter_bloc setup.

class FeatureBloc extends SideEffectBloc<FeatureEvent, FeatureState, FeatureSideEffect>{
  FeatureBloc() : super(FeatureState.initial());
}

Alternatives

Packages that do the same job and could replace side_effect_bloc.

Works with

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