append method
void
append(
- String appending, {
- bool distinct = false,
})
Implementation
void append(String appending, {bool distinct = false}) {
if (distinct && text.endsWith(appending)) {
L.d('要求不重复添加, 直接返回');
return;
}
if (selection.isValid) {
final beforeString = text.substring(0, selection.start);
final afterString = text.substring(selection.end);
text = beforeString + appending + afterString;
selection =
TextSelection.collapsed(offset: (beforeString + appending).length);
} else {
// 如果没在文字内部, 就直接加到最后
text += appending;
selection = TextSelection.collapsed(offset: text.length);
}
}