What's the difference betwe...
What's the difference betwe...
The main difference between async
and async*
in Dart is the type of result they return:
async
functions return a Future
, representing a single asynchronous result[1][2][3].async*
functions return a Stream
, representing a sequence of asynchronous results[1][2].Here's a more detailed comparison:
async
await
expression, then pauses until the awaited Future
completes[3].Future
that completes with the return value of the function[1][3].Example:
Future<int> doSomeLongTask() async {
await Future.delayed(Duration(seconds: 1));
return 42;
}
async*
yield
statement, then p...senior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào