setComposingRect method Null safety

void setComposingRect(
  1. Rect rect
)

Send the smallest rect that covers the text in the client that's currently being composed.

The given rect can not be null. If any of the 4 coordinates of the given Rect is not finite, a Rect of size (-1, -1) will be sent instead.

This information is used for positioning the IME candidates menu on each platform.

Implementation

void setComposingRect(Rect rect) {
  assert(rect != null);
  if (rect == _cachedRect) {
    return;
  }
  _cachedRect = rect;
  final Rect validRect = rect.isFinite ? rect : Offset.zero & const Size(-1, -1);
  TextInput._instance._setComposingTextRect(
    <String, dynamic>{
      'width': validRect.width,
      'height': validRect.height,
      'x': validRect.left,
      'y': validRect.top,
    },
  );
}