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