setItem method

void setItem(
  1. T item, [
  2. int? index
])

Implementation

void setItem(T item, [int? index]) {
  super.onNotifyWithCallback(() {
    var list = List<T>.from(items);
    if (index != null && itemCount >= index) {
      list.insert(index, item);
    } else {
      list.add(item);
    }
    items = list;
  });
}