getWordBoundary abstract method

TextRange getWordBoundary(
  1. 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

The TextPosition is treated as caret position, its TextPosition.affinity is used to determine which character this position points to. For example, the word boundary at TextPosition(offset: 5, affinity: TextPosition.upstream) of the string = 'Hello word' will return range (0, 5) because the position points to the character 'o' instead of the space.

Implementation

TextRange getWordBoundary(TextPosition position);