prefer_contains

Group: style

Maturity: stable

Linter v0.1.30

Since info is static, may be stale
recommendedflutterpedantic

View all Lint Rules

Using the Linter

DON'T use indexOf to see if a collection contains an element.

Calling indexOf to see if a collection contains something is difficult to read and may have poor performance.

Instead, prefer contains.

GOOD:

if (!lunchBox.contains('sandwich')) return 'so hungry...';

BAD:

if (lunchBox.indexOf('sandwich') == -1) return 'so hungry...';