updateItem method
FaderModel
updateItem(
- FaderModel model,
- ListedItemModel oldItem,
- ListedItemModel newItem
override
Implementation
@override
FaderModel updateItem(
FaderModel model, ListedItemModel oldItem, ListedItemModel newItem) {
List<ListedItemModel> currentItems =
model.items == null ? [] : model.items!;
var index = currentItems.indexOf(oldItem);
if (index != -1) {
var newItems = currentItems.map((e) => e).toList();
newItems[index] = newItem;
var newModel = model.copyWith(items: newItems);
return newModel;
} else {
throw Exception("Could not find $oldItem");
}
}