void main() {
Future<int> example() async {
await 1;
return 0;
}
// Future<T> function_name() async { await 1; return 0; }
}
What does async * mean in DART?
You add the async* keyword to make a function that returns
a bunch of future values one at a time which are returned
using keyword yield (which is used to return a value without
terminating the function execution)!
The results are wrapped in a Stream. An Example could be:
Stream<int> myStream() async* {
//wait for Duration of 3 Secs and yield a value,
for (int i = 0; i < 6; i++) {
await Future.delayed(Duration(seconds: 3));
yield i;
}
}
void main() {
Stream<int> instanceStream = myStream();
instanceStream.listen((data) {
print(data);
});
}