selectedItemById static method

DropdownItem? selectedItemById(
  1. List<DropdownItem> list,
  2. String id
)

selected item by id from dropdown

Implementation

static DropdownItem? selectedItemById(List<DropdownItem> list, String id) {
  DropdownItem? selectedItem;
  for (DropdownItem obj in list) {
    if (DropdownItem._equals(id, obj.id)) {
      selectedItem = obj;
      break;
    }
  }
  if (selectedItem == null && list.isNotEmpty) {
    selectedItem = list[0];
  }
  return selectedItem;
}