updateCows method Null safety

void updateCows(
  1. List<Cow> targetCows
)

Implementation

void updateCows(List<Cow> targetCows) {
  _cows = _cows.map((_) {
    Cow? targetCow = targetCows.firstWhereOrNull((targetCow) => targetCow == _);
    if (targetCow != null) {
      return targetCow;
    } else {
      return _;
    }
  }).toList();
  notifyListeners();
}