-
-
Save AbbasHoseini/bc3ac5fbeba864d69d7e76d8d768f552 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
/// رویدادهایی که به `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