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