bloc Flutter Interview Questions
3 questions
Advertisement
IntermediateState Management
What is the BLoC pattern in Flutter?
BLoC (Business Logic Component) separates UI from business logic by having the UI dispatch Events into a Bloc, which processes them and emits new States that the UI rebuilds from — all communication happens through a strict, unidirectional stream of Events and States.
IntermediateTesting
How do you unit test a Bloc or Cubit?
Use the bloc_test package's blocTest() helper, which lets you set up a Bloc, feed it events (or call Cubit methods), and assert on the exact sequence of emitted states — without needing any widget tree at all.
IntermediateState Management
What's the difference between Bloc and Cubit?
Cubit is a simplified version of Bloc — you call methods directly to emit new states, instead of dispatching Events that get mapped to states — trading some of Bloc's structure and traceability for less boilerplate.
Advertisement