getHandleAnchor method Null safety

  1. @override
Offset getHandleAnchor(
  1. TextSelectionHandleType type,
  2. double textLineHeight
)
override

Gets anchor for cupertino-style text selection handles.

See TextSelectionControls.getHandleAnchor.

Implementation

@override
Offset getHandleAnchor(TextSelectionHandleType type, double textLineHeight) {
  final Size handleSize;

  switch (type) {
    // The circle is at the top for the left handle, and the anchor point is
    // all the way at the bottom of the line.
    case TextSelectionHandleType.left:
      handleSize = getHandleSize(textLineHeight);
      return Offset(
        handleSize.width / 2,
        handleSize.height,
      );
    // The right handle is vertically flipped, and the anchor point is near
    // the top of the circle to give slight overlap.
    case TextSelectionHandleType.right:
      handleSize = getHandleSize(textLineHeight);
      return Offset(
        handleSize.width / 2,
        handleSize.height - 2 * _kSelectionHandleRadius + _kSelectionHandleOverlap,
      );
    // A collapsed handle anchors itself so that it's centered.
    case TextSelectionHandleType.collapsed:
      handleSize = getHandleSize(textLineHeight);
      return Offset(
        handleSize.width / 2,
        textLineHeight + (handleSize.height - textLineHeight) / 2,
      );
  }
}