Skip to content

Instantly share code, notes, and snippets.

@AbbasHoseini
Last active December 15, 2021 10:10
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/bc3ac5fbeba864d69d7e76d8d768f552 to your computer and use it in GitHub Desktop.
Save AbbasHoseini/bc3ac5fbeba864d69d7e76d8d768f552 to your computer and use it in GitHub Desktop.
/// رویدادهایی که به `counterBloc` واکنش نشان خواهند داد
abstract class CounterEvent {}
/// استیت افزایش را به بلاک اطلاعرسانی میکند
class Increment extends CounterEvent {}
/// A `CounterBloc` which handles converting `CounterEvent`s into `int`s.
///
class CounterBloc extends Bloc<CounterEvent, int> {
/// The initial state of the `CounterBloc` is 0.
CounterBloc() : super(0) {
/// When an `Increment` event is added,
/// the current `state` of the bloc is accessed via the `state` property
/// and a new state is emitted via `emit`.
on<Increment>((event, emit) => emit(state + 1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment