removeRows method

  1. @override
void removeRows(
  1. List<PlutoRow> rows, {
  2. bool notify = true,
})
inherited

Implementation

@override
void removeRows(
  List<PlutoRow> rows, {
  bool notify = true,
}) {
  if (rows.isEmpty) {
    return;
  }

  final Set<Key> removeKeys = Set.from(rows.map((e) => e.key));

  if (currentRowIdx != null &&
      refRows.length > currentRowIdx! &&
      removeKeys.contains(refRows[currentRowIdx!].key)) {
    resetCurrentState(notify: false);
  }

  Key? selectingCellKey;

  if (hasCurrentSelectingPosition) {
    selectingCellKey = refRows
        .originalList[currentSelectingPosition!.rowIdx!].cells.entries
        .elementAt(currentSelectingPosition!.columnIdx!)
        .value
        .key;
  }

  if (enabledRowGroups) {
    removeRowAndGroupByKey(removeKeys);
  } else {
    refRows.removeWhereFromOriginal((row) => removeKeys.contains(row.key));
  }

  updateCurrentCellPosition(notify: false);

  setCurrentSelectingPositionByCellKey(selectingCellKey, notify: false);

  currentSelectingRows.removeWhere((row) => removeKeys.contains(row.key));

  notifyListeners(notify, removeRows.hashCode);
}