r/FlutterDev • u/RandalSchwartz • Jul 18 '26
Plugin [Showcase] BlocSignal: Bridging BLoC & Cubit patterns with synchronous signals (v7)
Hey devs,
I wanted to share a new library I just released to pub.dev: BlocSignal (and its Flutter companion bloc_signals_flutter).
Classic BLoC/Cubit is fantastic for structuring business logic, but it relies on Streams under the hood, introducing asynchronous microtask delays.
BlocSignal replaces Streams with Rody Davis's reactive signals v7 primitives.
Key Features:
- BLoC & Cubit Parity: Override
onEventto handle classic BLoC input events, or use it as a Cubit directly by exposing public methods that callemit(state)(by setting the Event parameter tovoid). - Synchronous Propagation: Calling
emit(newState)propagates changes downstream immediately in the same frame—no microtask queues, no UI flickering. - Automatic State De-duplication: Signals compare states via
==and automatically filter out identical updates—saving redundant UI build cycles by default. - No Boilerplate Lifecycle: Closing a container automatically tears down all internally managed effects.
Quick Cubit Look:
class CounterCubit extends BlocSignal<void, int> {
CounterCubit() : super(initialState: 0);
void increment() => emit(stateValue + 1); // Synchronous & reactive!
}
Under the hood, the library has 100% test coverage and is structured as a clean Dart workspace.
- GitHub Repository: https://github.com/RandalSchwartz/BlocSignal
- Migration Guide (including Cubit migration): https://github.com/RandalSchwartz/BlocSignal/blob/main/MIGRATION.md
- Core package on Pub: https://pub.dev/packages/bloc_signals
- Flutter bindings on Pub: https://pub.dev/packages/bloc_signals_flutter
Would love to hear your thoughts and suggestions!
14
Upvotes
1
u/gambley Jul 18 '26
What about event transformers/mutex/lock? Since events are not driven by streams, default mutex could be included in the library for convenience to make it possible to have droppable/sequential events execution. You can check what I'm talking about in this package https://pub.dev/packages/control/versions/1.0.0-dev.1
1
u/Hackmodford Jul 18 '26
One thing I don’t understand. Don’t you lose one of the benefits of signals which is a surgical rebuild of widgets that depend on the specific signals?
Like in the example there is a state for the entire login screen (which is the bloc way), but would it be more efficient if each of the properties in that state object were signals?
1
u/Desperate_Mode_5340 Jul 19 '26
So in short instead of streams in bloc, it's sync. ? but isn't cubit already like that ?
1
u/TheManuz Jul 19 '26
Would you consider adding effects?
Generally speaking, how do you handle side effects with bloc pattern?
I've found that putting them in the state class will generally produce less clear states.
I've been using bloc_effects package, which introduce a third generics for effects, and can be mixed in a regular Bloc/Cubit.