Katipunero-
Eternal Poster
- Joined
- Mar 22, 2020
- Posts
- 790
- Reaction
- 318
- Points
- 312
Code:
void main() async {
print('Started.');
Stopwatch stopwatch = Stopwatch()..start();
String x = await helloAsync();
print(x);
print('helloAsync() executed in ${stopwatch.elapsed}');
}
Future<String> helloAsync() async{
await Future.delayed(Duration(seconds:5));
return 'Message from Future.';
}
Output:
Started.
Message from Future.
helloAsync() executed in 0:00:05.016700