# \[share\] verification of await keyword behaviour

**URL:** <https://forums.kodeco.com/t/share-verification-of-await-keyword-behaviour/184784>\
**Category:** Dart Apprentice: Beyond the Basics\
**Created:** [March 6, 2023, 3:10pm UTC](https://forums.kodeco.com/t/share-verification-of-await-keyword-behaviour/184784 "2023-03-06T15:10:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ellery](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ellery/32/110937_2.png) [@ellery](https://forums.kodeco.com/u/ellery)\
**Post date:** [March 6, 2023, 3:10pm UTC](https://forums.kodeco.com/t/share-verification-of-await-keyword-behaviour/184784/1 "2023-03-06T15:10:46Z")

</div>

I want to share how I verify the point: everything after `await` keyword is sent to event queue.  
When I first come across the code in the book below:

```dart
Future<void> main() async {
  print('Before the future');

  
  final value = await Future<int>.delayed(
    Duration(seconds: 1),
    () => 42,
  );
  print('Value: $value');
  print('After the future');
}

```

It look like to me that the last two lines are synchronous also. The `await` keyword just stop the program temporarily and run the `Future`, then go back to run the last two lines.

Until the book tells me _everything_ after the `await` keyword is sent to the event queue. I just want to verify this point. Therefore, I re-write the code as follows:

```dart
Future<void> main() async {
  print('Before the future');
  Future<int> futureFunction() {
    Future.microtask(
      () => print("put microtask queue"),
    );
    return Future.value(42);
  }
  final value = await futureFunction();
  print('Value: $value');
  print('After the future');
}

```

The print output `put microtask queue` exists before the last 2 print lines. Now, I am convinced the last two lines are also in event queue. This is because if the last two line is synchronous, they will have higher priority than the microtask queue. Then, the microtask print output should be at last.

---

<div class="post-metadata">

**Author:** ![suragch](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/suragch/32/109020_2.png) [@suragch](https://forums.kodeco.com/u/suragch)\
**Post date:** [March 7, 2023, 7:59am UTC](https://forums.kodeco.com/t/share-verification-of-await-keyword-behaviour/184784/2 "2023-03-07T07:59:47Z")

</div>

Just to make sure, you’re confirming that what the book says is true, right? Good job on putting it to the test.

---

<div class="post-metadata">

**Author:** ![ellery](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ellery/32/110937_2.png) [@ellery](https://forums.kodeco.com/u/ellery)\
**Post date:** [March 7, 2023, 8:05am UTC](https://forums.kodeco.com/t/share-verification-of-await-keyword-behaviour/184784/3 "2023-03-07T08:05:44Z")

</div>

Yes, I just want to confirm what the book says is true. Thank you for your explanation in the book.  
If I encounter this in my project, I probably will not think how it work as long as the code “works” for me.  
Really I think deeper and have a clearer understanding.

---

<div class="post-metadata">

**Author:** ![kpere](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/kpere/32/109586_2.png) [@kpere](https://forums.kodeco.com/u/kpere)\
**Post date:** [August 4, 2023, 11:05am UTC](https://forums.kodeco.com/t/share-verification-of-await-keyword-behaviour/184784/4 "2023-08-04T11:05:24Z")

</div>

Thank you @ellery for applying what you learned in the book and contributing to the forum. Keep up the great work! Your participation is valued, and we look forward to more of your insights. Happy learning!

---

<div class="post-metadata">

**Author:** ![kpere](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/kpere/32/109586_2.png) [@kpere](https://forums.kodeco.com/u/kpere)\
**Post date:** [August 4, 2023, 11:05am UTC](https://forums.kodeco.com/t/share-verification-of-await-keyword-behaviour/184784/5 "2023-08-04T11:05:55Z")

</div>

Thank you, @suragch , for your prompt and helpful response to the question. Your expertise and assistance are greatly appreciated!

---

<div class="post-metadata">

**Author:** ![kpere](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/kpere/32/109586_2.png) [@kpere](https://forums.kodeco.com/u/kpere)\
**Post date:** [August 4, 2023, 11:06am UTC](https://forums.kodeco.com/t/share-verification-of-await-keyword-behaviour/184784/6 "2023-08-04T11:06:04Z")

</div>

Closed on August 4, 2023, 11:06am UTC


