addItem method

bool addItem(
  1. ItemModel? item
)

Implementation

bool addItem(ItemModel? item) {
  if (item == null) return false;
  int index = list.indexWhere((element) => element.id == item.id);
  if (index == -1) {
    list.add(item);
    return true;
  }
  return false;
}