-
-
Save AbbasHoseini/f17638bfcb76e66bf5be83132c3d17f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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