What problem does it solve?
This skill documents a consistent pattern for managing Cubit state and orchestrating UI side effects in the Unyo Flutter app so business logic can trigger navigation, dialogs, and snackbars without holding BuildContext, avoid mutable state, and prevent memory leaks from subscriptions.
Core Features & Use Cases
- Immutable Freezed states with effects: States implement HasEffects and include a default effects list used to express navigation and feedback intents from the cubit.
- Cubits with EffectMixin: Cubits mix in EffectMixin, implement copyStateWithEffects and a logger, and emit state changes and AppEffect instances for the UI to handle.
- UI effect handler & DI wiring: BlocListener reads state.effects, delegates to AppEffectHandler to execute routes/dialogs/snackbars, then calls clearEffects; cubits are registered via the DI locator and subscribe to notifiers with proper cancellation in close.
Quick Start
Create a Freezed state that implements HasEffects with a default effects list, implement a Cubit that mixes in EffectMixin and emits state.copyWith(effects: ...), register the cubit in the DI locator, and add a BlocListener in the UI to handle and clear AppEffect instances.