consume-effect

Consume one-time Effect<T> fields from state using context.effect() in widget builds.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Consumes one-time effects emitted by state (Effect<T>) within UI widgets by using context.effect(), allowing the UI to react once per event and prevent re-triggering.

Core Features & Use Cases

  • Read and consume Effect<T> fields from state in widgets
  • Automatically mark effects as spent after consumption
  • Trigger side effects (snackbars, navigation, dialogs) when new effects arrive
  • Safely handle multiple effects across different Cubits

Quick Start

Use context.effect() in the widget build to read and react to the first new effect, then respond in the UI accordingly.

Frequently Asked Questions about consume-effect

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

FAQPage Schema
How do I consume one-time state effects in Flutter widgets without triggering side effects during build?

To consume one-time effects safely during the build phase, use `context.effect()` to read `Effect<T>` fields and mark them as spent. This prevents side effects like showing snackbars or navigating from re-triggering on widget rebuilds.

What is the best way to handle one-time events like navigation or dialogs from a Cubit in Flutter?

The best way to handle one-time events from a Cubit is by emitting `Effect<T>` fields from the state and consuming them in the UI using `context.effect()`, ensuring the navigation or dialog is triggered only once per event.

How do I read and mark a state effect as spent so it doesn't fire multiple times in Flutter?

You read and mark a state effect as spent by accessing it via `context.effect()` in your widget's build method. This method reads the new value and automatically marks the effect as spent to prevent multiple triggers.

Can I handle multiple one-time effects from different Cubits simultaneously in the same widget?

Yes, you can handle multiple one-time effects from different Cubits simultaneously. The `context.effect()` pattern safely manages and consumes distinct `Effect<T>` fields across multiple Cubit states within the same widget build.

Why does my Flutter side effect trigger repeatedly during the build method, and how do I fix it?

Side effects trigger repeatedly because standard state variables are re-read on every build. Fix this by using `context.effect()` to consume the `Effect<T>` field, which marks it as spent after the first read.