📜  flutter indexwhere 示例 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:01.826000             🧑  作者: Mango

代码示例1
/// Find a person in the list using indexWhere method.
void findPersonUsingIndexWhere(List people,
    String personName) {
  // Find the index of person. If not found, index = -1
  final index = people.indexWhere((element) =>
        element.name == personName);
  if (index >= 0) {
    print('Using indexWhere: ${people[index]}');
  }
}