updateItem method

StoreList<T> updateItem(
  1. Object? id,
  2. T? value
)

Returns a StoreList with updated by id identificator value object.

Implementation

StoreList<T> updateItem(Object? id, T? value) {
  final self = this;

  if (id == null || value == null) {
    return self;
  }

  final updateIndex = items.indexWhere((e) => e.id == id);

  if (updateIndex < 0) {
    return self;
  }

  final updatedItems = items.rebuild((b) => b[updateIndex] = value);

  return StoreList(updatedItems);
}