replaceFirstItemWhere method
Replaces first item that matches the test with a newItem.
Implementation
bool replaceFirstItemWhere({
required bool Function(T item) test,
required T newItem,
}) {
var index = _newItems.indexWhere(test);
if (index != -1) {
_newItems[index] = newItem;
notifyListeners();
return true;
}
index = _oldItems.indexWhere(test);
if (index != -1) {
_oldItems[index] = newItem;
notifyListeners();
return true;
}
return false;
}