currentWordIndex property

int get currentWordIndex

Gets the index of the current word where the cursor is located.

Implementation

int get currentWordIndex {
  var cursorPos = selection.base.offset;
  var textpart = text.first(cursorPos);
  var parts = textpart.splitWords(WordSplitMode.keepSplitters);
  var curIndex = parts.length - 1;
  curIndex = curIndex.clampMin(0);
  return curIndex;
}