Flutter ● ● ●

Kodebits Day 69: Spread Copy Independence

Aug 3 2026
Practice collections with a short dart challenge.

What is the output?

void main() {
  final a = [1, 2];
  final b = [...a, 3];
  b[0] = 9;
  print(a[0] + b.length);
}


Try it in the online Dart Playground →

[spoiler title="Solution"]

Answer:

4

Explanation:

The spread copies values, so mutating b does not change a.

[/spoiler]


Further Reading