BLoC Pattern

Business logic components with streams and events

BLoC separates business logic from UI. Events flow in, states flow out. Try the interactive counter.

Business Logic Component. Events go in, states come out. Separates UI from business logic using streams.

// BLoC pattern:
// UI sends Events -> BLoC
// BLoC emits States -> UI

// Event: what happened
abstract class CounterEvent {}
class Increment extends CounterEvent {}
class Decrement extends CounterEvent {}

// State: what to show
class CounterState {
  final int count;
  CounterState(this.count);
}
Event
->
BLoC
->
State
0
Event Log
No events yet