Skip to main content

avoid-empty-spread

added in: 1.15.0
🛠
Pro+
preset: recommended

Warns when a collection literal in spread (...[]) has no elements.

Example

❌ Bad:

void fn(bool flag) {
final another = [
...<String>[], // LINT
if (flag) ...<String>[], // LINT
];
}

✅ Good:

void fn(bool flag) {
final another = [
...<String>['some', 'elements'],
];
}