bringIntoView method

  1. @override
void bringIntoView(
  1. TextPosition position
)
override

Brings the provided TextPosition into the visible area of the text input.

Implementation

@override
void bringIntoView(TextPosition position) {
  // Ignore errors if position is invalid (i.e. paste on iOS when editor
  // has no content and user pasted from toolbar)
  try {
    final localRect = renderEditor.getLocalRectForCaret(position);
    final targetOffset = _getOffsetToRevealCaret(localRect, position);

    if (scrollController.hasClients) {
      scrollController.jumpTo(targetOffset.offset);
    }
    renderEditor.showOnScreen(rect: targetOffset.rect);
  } catch (_) {}
}