Collection Literals
Spread
...
...other flattens another iterable into the literal in place. Useful for prepending or appending.
Program
Play the program to assemble a list from a head, tail, and bookend numbers.
spread.dart
void main() {
var head = [1, 2];
var tail = [3, 4];
var all = [0, ...head, ...tail, 5];
print(all);
}
spread
`...xs` flattens `xs` into the surrounding literal.
null-aware spread
Use `...?xs` to skip the spread when `xs` is null.
composition
Combine literal elements with spread elements freely.