prefer_iterable_first

SeverityQuick FixOptions
Info

Details

DO use iterable.first instead of iterable[0] or iterable.elementAt(0).

Bad
const numbers = [1, 2, 3];

final firstNumber = numbers[0];
// or
final firstNumber = numbers.elementAt(0);
Good
const numbers = [1, 2, 3];
final firstNumber = numbers.first;

Usage

To enable the prefer_iterable_first rule, add prefer_iterable_first under custom_lint > rules in your analysis_options.yaml file:

custom_lint:
  rules:
    - prefer_iterable_first