Skip to content

Instantly share code, notes, and snippets.

@AbbasHoseini
Created December 15, 2021 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbbasHoseini/f17638bfcb76e66bf5be83132c3d17f7 to your computer and use it in GitHub Desktop.
Save AbbasHoseini/f17638bfcb76e66bf5be83132c3d17f7 to your computer and use it in GitHub Desktop.
abstract class CounterEvent {}
class Increment extends CounterEvent {}
class CounterBloc extends Bloc<CounterEvent, int> {
CounterBloc() : super(0) {
on<Increment>((event, emit) => emit(state + 1));
}
@override
void onEvent(CounterEvent event) {
super.onEvent(event);
print(event);
}
@override
void onChange(Change<int> change) {
super.onChange(change);
print(change);
}
@override
void onTransition(Transition<CounterEvent, int> transition) {
super.onTransition(transition);
print(transition);
}
@override
void onError(Object error, StackTrace stackTrace) {
print('$error, $stackTrace');
super.onError(error, stackTrace);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment