15
6
DO use iterable.first instead of iterable[0] or iterable.elementAt(0).
iterable.first
iterable[0]
iterable.elementAt(0)
const numbers = [1, 2, 3]; final firstNumber = numbers[0]; // or final firstNumber = numbers.elementAt(0);
const numbers = [1, 2, 3]; final firstNumber = numbers.first;
To enable the prefer_iterable_first rule, add prefer_iterable_first under custom_lint > rules in your analysis_options.yaml file:
prefer_iterable_first
analysis_options.yaml
custom_lint: rules: - prefer_iterable_first