Skip to content

Instantly share code, notes, and snippets.

@AbbasHoseini
Created December 15, 2021 09:52
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/0e700c63f5d340cd469dd0b2b3f95805 to your computer and use it in GitHub Desktop.
Save AbbasHoseini/0e700c63f5d340cd469dd0b2b3f95805 to your computer and use it in GitHub Desktop.
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