setTextSelection method

void setTextSelection(
  1. TextSelection t
)

Implementation

void setTextSelection(TextSelection t) {
  if (textSelection == t) {
    return;
  }

  final containsSelection = containsTextSelection();
  if (_attachedToCursorController) {
    cursorCont.removeListener(markNeedsLayout);
    cursorCont.color.removeListener(safeMarkNeedsPaint);
    _attachedToCursorController = false;
  }

  textSelection = t;
  _selectedRects = null;
  _containsCursor = null;
  if (attached && containsCursor()) {
    cursorCont.addListener(markNeedsLayout);
    cursorCont.color.addListener(safeMarkNeedsPaint);
    _attachedToCursorController = true;
  }

  if (containsSelection || containsTextSelection()) {
    safeMarkNeedsPaint();
  }
}