bloc_action_listener
1.1.1, released 4 weeks ago by lanars.com
Adds actions stream to Bloc and Cubit to process UI events like dialogs or snackbars.
WASM-ready
What it does
Extends Bloc and Cubit with a mixin to dispatch one-off UI actions that are separate from state changes. Provides a BlocActionListener widget to listen to and process these actions in the UI.
AI-written summary of version 1.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to show dialogs or snackbars from a Bloc or Cubit without tying them to state changes
- You want a dedicated UI action stream alongside your flutter_bloc architecture
Skip it when
- State changes alone are sufficient for driving your UI side effects
- You are not using flutter_bloc in your application
Strengths
- Simplifies triggering one-off UI events from business logic
- Familiar API style matching standard flutter_bloc patterns
Weaknesses
- Adds an extra layer of abstraction for side effects
- Limited to flutter_bloc ecosystem
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
not documented
BlocActionListener<ExampleCubit, ExampleAction>(
listener: (context, action) {
if (action is ShowSnackbarAction) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(action.content)));
}
},
);Alternatives
Packages that do the same job and could replace bloc_action_listener.
Works with
Packages commonly used together with bloc_action_listener: ones it builds on, ones built on it, and its own family.