Tsallaka zuwa abun ciki
Justice Tech School

Iterable Helpers

first, last, isEmpty, single, takeWhile and skipWhile read collections.

Example
void main() {
  var a = [1, 2, 3, 4, 5];
  print(a.first);
  print(a.takeWhile((x) => x < 3).toList());
  print(a.skipWhile((x) => x < 3).toList());
  print(a.isEmpty);
  print(a.firstWhere((x) => x > 3));
}

Exercise

First match.

a.((x) => x > 3)

Quiz Test

What does takeWhile do?

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