Async Coding With Dart: Async/Await

MIB Coder
Nov 10, 2019

--

What are you going to learn : How to use Async/await to call a async function(which is returning Future/Stream)?

To read the latest version of this article click here: https://mibcoder.com

Async / await in dart

Where to use Async/await?

By using “Await” we can call any async function(who’s return type Future or Stream) and get response in same statement.

These are to thing to call async function in single statement:

i- Mark function with “async” in which we have to call “async function”.

void useFutureMethodTwo()async{................
}

ii- write “await” in front of “async function” call

String onValue=await getFuture();

Note: Program will wait at this statement until it get response from async function.

To handle error use try and catch:

Here is complete example:

use of async and await to call async function

Thanks for reading, if you like please follow me.

--

--