Skip to content
Justice Tech School

toList, toSet and expand

Convert between collections and flatten nested ones.

Example
var a = [1, 2, 2, 3];
print(a.toSet());
print(a.toSet().toList());
print([[1], [2, 3]].expand((x) => x).toList());
print({"a": 1}.entries.map((e) => e.key).toList());

Exercise

Remove duplicates.

a.().toList()

Quiz Test

What does expand do?

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