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