Skip to content

Instantly share code, notes, and snippets.

@chimon2000
Last active July 16, 2020 07:06
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 chimon2000/f78515d0eda5d673fe1d9ab9dd9a20f0 to your computer and use it in GitHub Desktop.
Save chimon2000/f78515d0eda5d673fe1d9ab9dd9a20f0 to your computer and use it in GitHub Desktop.
Bloc counter
enum CounterEvent { increment }
class CounterBloc extends Bloc<CounterEvent, int> {
CounterBloc() : super(0);
@override
Stream<int> mapEventToState(CounterEvent event) async* {
switch (event) {
case CounterEvent.increment:
yield state + 1;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment