getSelectionBetween method
TextNodeSelection
getSelectionBetween({
- required NodePosition basePosition,
- required NodePosition extentPosition,
override
Returns a NodeSelection within this component's DocumentNode that
spans from basePosition
to extentPosition
.
Throws an exception if basePosition
or extentPosition
are
incompatible with this component's node type.
Implementation
@override
TextNodeSelection getSelectionBetween({
required NodePosition basePosition,
required NodePosition extentPosition,
}) {
if (basePosition is! TextNodePosition) {
throw Exception('Expected a basePosition of type TextNodePosition but received: $basePosition');
}
if (extentPosition is! TextNodePosition) {
throw Exception('Expected an extentPosition of type TextNodePosition but received: $extentPosition');
}
return TextNodeSelection(
baseOffset: basePosition.offset,
extentOffset: extentPosition.offset,
);
}