getCursorScreenPosition method

Offset? getCursorScreenPosition(
  1. TextEditingController controller,
  2. ScreenRect windowBounds, {
  3. CursorAnchor anchor = CursorAnchor.bottomLeft,
})

Get a cursor anchor point in screen coordinates.

This is the most common use case for palettes - get screen position to show a menu below the cursor.

windowBounds - The palette window's bounds from PaletteSelf.screenRect.

Implementation

Offset? getCursorScreenPosition(
  TextEditingController controller,
  ScreenRect windowBounds, {
  CursorAnchor anchor = CursorAnchor.bottomLeft,
}) {
  final viewPos = getCursorAnchorInView(controller, anchor: anchor);
  if (viewPos == null) return null;

  return windowBounds.localToScreen(viewPos);
}