getWordBoundary method

TextRange getWordBoundary (TextPosition position)

Returns the text range of the word at the given offset. Characters not part of a word, such as spaces, symbols, and punctuation, have word breaks on both sides. In such cases, this method will return a text range that contains the given text position.

Word boundaries are defined more precisely in Unicode Standard Annex #29 www.unicode.org/reports/tr29/#Word_Boundaries.

Valid only after layout.

Implementation

TextRange getWordBoundary(TextPosition position) {
  assert(!debugNeedsLayout);
  _layoutTextWithConstraints(constraints);
  return _textPainter.getWordBoundary(position);
}