Tsallaka zuwa abun ciki
Justice Tech School

Generators: sync* and async*

sync* returns an Iterable and yield produces values lazily.

Example
Iterable<int> count(int n) sync* {
  for (var i = 1; i <= n; i++) yield i;
}
print(count(3).toList());
print(count(5).where((x) => x.isOdd).toList());

Exercise

Produce a value.

 i;

Quiz Test

What does sync* return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.