What is the difference between Bloc and Cubit?
Cubit is a simplified Bloc that emits states directly via methods, with no Events. Bloc requires an explici...
15 questions
Deep dive: events, transformers, testing, patterns
Cubit is a simplified Bloc that emits states directly via methods, with no Events. Bloc requires an explici...
BlocBuilder: rebuilds UI on state changes. BlocListener: side effects (navigation, snackbars) without rebui...
Event transformers control how a Bloc processes multiple events of the same type. The default is sequential...
BlocObserver is a global hook that intercepts every Bloc/Cubit event, state transition, and error in the ap...
Use BlocProvider to create and provide a Bloc to descendants. Access it with context.read<MyBloc>() (no reb...
Bloc is built on Dart Streams. Each on<Event> handler receives an Emitter<State> that wraps emit() with can...
Sealed classes (Dart 3.0+) make state unions exhaustive. The compiler forces you to handle every subclass i...
Use blocTest() from the bloc_test package. Provide: bloc (factory), seed (initial state), act (events to ad...
Never hold a direct reference from one Bloc to another. Instead, use a shared Repository stream (both Blocs...
HydratedBloc automatically saves and restores Bloc state to/from local storage. Override toJson() and fromJ...
Model each form field as a Formz input with pure/dirty validation. Each field change dispatches an event. T...
Model pagination state with hasReachedMax flag, current items list, and status. Add a FetchNextPage event. ...
Freezed generates immutable data classes with copyWith(), == and hashCode, pattern matching (when/map), and...
RepositoryProvider makes a repository available to all widgets and Blocs below it in the tree. BlocProvider...
Navigation is a UI concern — Blocs should not call Navigator.push(). Instead, emit a navigation state (e.g....