# Asynchrony support

Dart библиотеки все асинхронные, все обернуто в Future и Stream объекты.

```dart
Future<String> lookUpVersion() async => '1.0.0';

await lookUpVersion();

Future<void> checkVersion() async {
  var version = await lookUpVersion();
  // Do something with version
}
```

Handling Streams

Есть два способа получить значения из Stream:

* Use `async` and an *asynchronous for loop* (`await for`).
* Use the Stream API, as described [in the library tour](https://dart.dev/guides/libraries/library-tour#stream).

await for использовать только в том случае, если мы хотим дождаться все результаты из Stream. Во многих случаях это лучше не использовать: например, в UI Stream бесконечен.

```dart
await for (varOrType identifier in expression) {
  // Executes each time the stream emits a value.
}
```

For more information about asynchronous programming, in general, see the [dart:async](https://dart.dev/guides/libraries/library-tour#dartasync---asynchronous-programming) section of the library tour.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://appsecurity.gitbook.io/devops/ppc/ppc-langs/frontend/dart-flutter/dart/asynchrony-support.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
