setContent method

void setContent(
  1. String newText,
  2. List<UStyleSpan> newSpans, {
  3. int? caret,
})

Replace the whole styled content in one shot.

Implementation

void setContent(String newText, List<UStyleSpan> newSpans, {int? caret}) {
  value = TextEditingValue(
    text: newText,
    selection: TextSelection.collapsed(offset: (caret ?? newText.length).clamp(0, newText.length)),
  );
  spans
    ..clear()
    ..addAll(newSpans.map((UStyleSpan sp) => sp.copy()));
  normalize();
  notifyListeners();
}