# updateItem method Null safety

1. @override

BookletModel updateItem(

1. BookletModel model,
2. SectionModel oldItem,
3. 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");
      }
    }