Flutter ● ● ○

Kodebits Day 43: Where Then Fold

Jun 19 2026
Practice collections with a short dart challenge.

What does this print?

void main() {
  final xs = [7, 8, 6, 3];
  final out = xs
    .where((e) => e > 6)
    .fold(0, (a, b) => a + b);
  print(out);
}


Try it in the online Dart Playground →

[spoiler title="Solution"]

Answer:

15

Explanation:

where filters values and fold accumulates them into one sum.

[/spoiler]


Further Reading