본문 바로가기
Flutter

[Flutter] dart get index of list by item

by hymndaniel 2022. 4. 27.
final notes = <String>['do', 're', 'mi', 're'];
final index = notes.indexOf('fa'); // -1

 

Reference

https://api.dart.dev/stable/2.16.1/dart-core/List/indexOf.html

 

indexOf method - List class - dart:core library - Dart API

int indexOf(E element, [int start = 0] ) The first index of element in this list. Searches the list from index start to the end of the list. The first time an object o is encountered so that o == element, the index of o is returned. final notes = ['do', 'r

api.dart.dev

 

728x90