moveRowsByIndex method
void
moveRowsByIndex(})
inherited
Implementation
@override
void moveRowsByIndex(
List<PlutoRow> rows,
int? indexToMove, {
bool notify = true,
}) {
if (rows.isEmpty || indexToMove == null) {
return;
}
if (indexToMove + rows.length > refRows.length) {
indexToMove = refRows.length - rows.length;
}
if (isPaginated &&
page > 1 &&
indexToMove + pageRangeFrom > refRows.originalLength - 1) {
indexToMove = refRows.originalLength - 1;
}
final Set<Key> removeKeys = Set.from(rows.map((e) => e.key));
refRows.removeWhereFromOriginal((e) => removeKeys.contains(e.key));
refRows.insertAll(indexToMove, rows);
int sortIdx = 0;
for (var element in refRows.originalList) {
element.sortIdx = sortIdx++;
}
updateCurrentCellPosition(notify: false);
if (onRowsMoved != null) {
onRowsMoved!(PlutoGridOnRowsMovedEvent(
idx: indexToMove,
rows: rows,
));
}
notifyListeners(notify, moveRowsByIndex.hashCode);
}