-
-
Save AbbasHoseini/0e700c63f5d340cd469dd0b2b3f95805 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
Future<void> main() async { | |
/// Create a `CounterBloc` instance. | |
final bloc = CounterBloc(); | |
/// Access the state of the `bloc` via `state`. | |
print(bloc.state); // 0 | |
/// Interact with the `bloc` to trigger `state` changes. | |
bloc.add(Increment()); | |
/// Wait for next iteration of the event-loop | |
/// to ensure event has been processed. | |
await Future.delayed(Duration.zero); | |
/// Access the new `state`. | |
print(bloc.state); // 1 | |
/// Close the `bloc` when it is no longer needed. | |
await bloc.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment