firstIndex property

int firstIndex

Index of the first element or -1 if the collection is empty.

[1, 2, 3].firstIndex; // 0

[].firstIndex; // -1

Implementation

int get firstIndex => isNotEmpty ? 0 : -1;