setViewHeight method

void setViewHeight(
  1. double viewHeight
)

Call this whenever the Flutter view height is known (e.g. in _updateImeCaretRect). Stores the height and re-sends the transform so the macOS plugin can map caret rect → screen rect correctly.

The macOS FlutterTextInputPlugin applies _editableTransform to the caret rect before calling fromView convertRect:toView:nil. Without a Y-flip the plugin treats Flutter's top-left Y as Cocoa's bottom-left Y, Stores the Flutter view height and sends an explicit identity transform to reset any previously-set (potentially corrupted) _editableTransform in the macOS plugin.

Implementation

void setViewHeight(double viewHeight) {
  _lastViewHeight = viewHeight;
  if (_connection == null || !_connection!.attached) return;
  // On web, setEditableSizeAndTransform is handled by _updateWebImePosition()
  // which sends the real render box transform. Don't override it with a dummy.
  if (kIsWeb) return;
  _connection!.setEditableSizeAndTransform(
    const Size(9999, 9999),
    Matrix4.identity(),
  );
}