Skip to main content

avoid-slow-collection-methods

Warns when an invocation is a slow sync* invocation.

Using sync* invocations can result in a ~2 times slower code compared to other approaches.

Additionally, this rule highlights .expand() usages as replacing them with a spread gives ~3 times performance difference. See the second link for more details.

Additional resources:

Example

❌ Bad:

void fn() {
const iterable = [null, 2, 3, 4, 5, 6, 7, 8, 9];

iterable.whereNotNull(); // LINT
}

✅ Good:

void fn() {
const iterable = [null, 2, 3, 4, 5, 6, 7, 8, 9];

iterable.whereType<int>();
}