selectedText property
String
get
selectedText
Implementation
String get selectedText {
final currentSelection = selection;
if (!currentSelection.isValid) {
return '';
}
if (currentSelection.isCollapsed) {
return '';
}
final start = currentSelection.start.clamp(0, text.length).toInt();
final end = currentSelection.end.clamp(0, text.length).toInt();
if (start >= end) {
return '';
}
return text.substring(start, end);
}