HeaderUserSelectionModel.fromAnchorFocus constructor
HeaderUserSelectionModel.fromAnchorFocus({
- String? id,
- required int anchor,
- required int focus,
- required Axis axis,
- SelectionStyle? style,
Create a HeaderUserSelectionModel given its edges
(anchor
and focus
).
if id
is omitted, an uuid is generated.
Since this selection is simply a Range
, we convert anchor
and focus
into range's start
and end
values.
Implementation
factory HeaderUserSelectionModel.fromAnchorFocus({
String? id,
required int anchor,
required int focus,
required Axis axis,
SelectionStyle? style,
}) {
final start = min(anchor, focus);
// Focus and anchor are inclusive, end on the range is not.
final end = max(anchor, focus) + 1;
final anchorEdge = anchor <= focus ? RangeEdge.leading : RangeEdge.trailing;
return HeaderUserSelectionModel._(
id: id,
anchorEdge: anchorEdge,
start: start,
end: end,
boundedAxis: axis,
style: style,
);
}