getResultBasedOnRect method Null safety
Determines SelectionResult purely based on the target rectangle.
This method returns SelectionResult.end if the point
is inside the
targetRect
. Returns SelectionResult.previous if the point
is
considered to be lower than targetRect
in screen order. Returns
SelectionResult.next if the point is considered to be higher than
targetRect
in screen order.
Implementation
static SelectionResult getResultBasedOnRect(Rect targetRect, Offset point) {
if (targetRect.contains(point)) {
return SelectionResult.end;
}
if (point.dy < targetRect.top) {
return SelectionResult.previous;
}
if (point.dy > targetRect.bottom) {
return SelectionResult.next;
}
return point.dx >= targetRect.right
? SelectionResult.next
: SelectionResult.previous;
}