lastIndexWhere 抽象方法
列表中满足给定 test 条件的最后一个索引。
从索引 start 开始搜索列表到 0。当遇到第一个满足 test(o) 为真的对象 o 时,返回 o 的索引。如果省略 start,则默认为列表的 长度。
final notes = <String>['do', 're', 'mi', 're'];
final first = notes.lastIndexWhere((note) => note.startsWith('r')); // 3
final second = notes.lastIndexWhere((note) => note.startsWith('r'),
2); // 1
如果未找到 element,则返回 -1。
final notes = <String>['do', 're', 'mi', 're'];
final index = notes.lastIndexWhere((note) => note.startsWith('k'));
print(index); // -1
实现
int lastIndexWhere(bool test(E element), [int? start]);