Skip to main content

prefer-add-all

added in: 1.24.0
Pro+

Suggests using .addAll() instead of multiple .add() invocations.

Example

❌ Bad:

void fn(List<String> values) {
values.add('first');

// LINT: Prefer 'addAll()' over multiple 'add()' invocations.
values.add('second');
}

✅ Good:

void fn(List<String> values) {
values.addAll(['first', 'second']);
}