snapCursorOffset static method

int snapCursorOffset(
  1. String text,
  2. int offset
)

Implementation

static int snapCursorOffset(String text, int offset) {
  if (text.isEmpty) return offset;
  return FragmentOperations.adjustIndex(text, offset.clamp(0, text.length));
}