updateLastSelectionToCellSelection method
UserSelectionState
updateLastSelectionToCellSelection({
- IntVector2? anchor,
- required IntVector2 focus,
Transform the last selection on selections into a
CellUserSelectionModel with anchor
and focus
.
anchor
defaults to the last selections
UserSelectionModel.anchorCoordinate.
Implementation
UserSelectionState updateLastSelectionToCellSelection({
IntVector2? anchor,
required IntVector2 focus,
}) {
final lastSelection = selections.last;
final effectiveAnchor = anchor ?? lastSelection.anchorCoordinate;
final builder = selections.toBuilder();
builder
..take(selections.length - 1)
..add(
CellUserSelectionModel.fromSelectionModel(
lastSelection,
anchor: effectiveAnchor,
focus: focus,
),
);
return UserSelectionState._(builder.build());
}