selectedItemByValue static method

DropdownItem? selectedItemByValue(
  1. List<DropdownItem> list,
  2. String value
)

selected item by value from dropdown

Implementation

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