getCursorAnchorInView method
Offset?
getCursorAnchorInView(
- TextEditingController controller, {
- CursorAnchor anchor = CursorAnchor.bottomLeft,
Get a specific anchor point of the cursor in view coordinates.
Common anchors:
bottomLeft- for dropdown menus below cursortopLeft- for tooltips above cursor
Implementation
Offset? getCursorAnchorInView(
TextEditingController controller, {
CursorAnchor anchor = CursorAnchor.bottomLeft,
}) {
final rect = getCursorRectInView(controller);
if (rect == null) return null;
return switch (anchor) {
CursorAnchor.topLeft => Offset(rect.left, rect.top),
CursorAnchor.topRight => Offset(rect.right, rect.top),
CursorAnchor.bottomLeft => Offset(rect.left, rect.bottom),
CursorAnchor.bottomRight => Offset(rect.right, rect.bottom),
CursorAnchor.center => rect.center,
};
}