replace-bloc-listener

Migrate BlocListener side effects to explicit Effects in Cubit state using context.effect().

7|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/marcglasberg/bloc_superpowers --skill replace-bloc-listener
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: replace-bloc-listener
Source: https://github.com/marcglasberg/bloc_superpowers/tree/main/.claude/skills/replace-bloc-listener
Command: npx skills add https://github.com/marcglasberg/bloc_superpowers --skill replace-bloc-listener

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

BlocListener is a convenient but implicit mechanism to react to state changes, which can lead to scattered logic and missed side effects. This Skill replaces BlocListener usage with an explicit, effect-based approach that ties side effects directly to state via an Effect field and context.effect().

Core Features & Use Cases

  • Replace implicit BlocListener patterns with explicit Effects stored in state and emitted by Cubits.
  • Centralize side effects such as navigation, dialogs, or snackbars in a predictable, testable way.
  • Easily migrate multiple BlocListeners by adding Effect fields, updating copyWith, and emitting effects in Cubits.

Quick Start

Identify BlocListener usages in your UI and migrate them by adding an Effect field to the state, emitting effects from the Cubit, and replacing BlocListener with context.effect() in the widget tree.

Frequently Asked Questions about replace-bloc-listener

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace BlocListener with explicit Effects in Flutter?

To replace BlocListener with explicit Effects in Flutter, add an Effect field to your state class, update copyWith, emit the effects from your Cubit, and read them in widgets using context.effect(). This centralizes side effects like navigation and dialogs directly into state.

Why should I use explicit Effects instead of BlocListener for side effects?

Explicit Effects improve reliability over BlocListener by tying side effects directly to state, preventing scattered logic and missed reactions. Storing effects in state makes outcomes predictable and testable, replacing the implicit BlocListener mechanism with a transparent, traceable approach.

What is the step by step process to migrate BlocListener to context.effect()?

The migration workflow involves adding an Effect field to your state object, updating the copyWith method to handle it, emitting the Effect from your Cubit during state changes, and finally replacing BlocListener in the widget tree with context.effect() to read and react to the emitted effect.

Does this explicit Effect pattern work with Cubit and bloc_superpowers?

Yes, this explicit Effect pattern works with Cubit and bloc_superpowers patterns. It is specifically designed for Flutter apps using bloc_superpowers to migrate implicit BlocListener side effects into an explicit, state-stored Effect field emitted by Cubits and consumed via context.effect().

Can I centralize navigation and snackbar side effects in Flutter state?

Yes, you can centralize navigation, dialogs, and snackbars by storing them as an explicit Effect field in your state. Emitting these side effects from Cubits and reading them via context.effect() ensures they are handled predictably and are fully testable.

What are the limitations of using explicit Effects instead of BlocListener?

Using explicit Effects requires modifying your state objects and copyWith methods, adding migration overhead compared to BlocListener. You must manually manage adding Effect fields for every new side effect and ensure context.effect() properly reads them in the widget tree.