setOrInsertString method
void
setOrInsertString(
- String s
)
Implementation
void setOrInsertString(String s) {
final textValue = value;
final curSelection = textValue.selection;
String text;
int offset;
if (curSelection.start == curSelection.end && curSelection.start == -1) {
text = s;
offset = s.length;
} else {
text = textValue.text.replaceRange(curSelection.start, curSelection.end, s);
offset = curSelection.start + s.length;
}
value = TextEditingValue(
text: text,
selection: TextSelection.fromPosition(TextPosition(offset: offset)),
);
}