getWordBoundary method

TextRange getWordBoundary (TextPosition position)

Returns the TextRange of the word at the given TextPosition.

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 offset, offset+1. Word boundaries are defined more precisely in Unicode Standard Annex #29 http://www.unicode.org/reports/tr29/#Word_Boundaries

Implementation

TextRange getWordBoundary(TextPosition position) {
  final List<int> boundary = _getWordBoundary(position.offset);
  return TextRange(start: boundary[0], end: boundary[1]);
}