toggleAttribute method
Toggle a boolean attribute over the current selection. With a collapsed selection the attribute is queued for the next typed characters.
Implementation
void toggleAttribute(UInlineAttr attr) {
final TextSelection sel = selection;
if (!sel.isValid) return;
if (sel.isCollapsed) {
if (pending.containsKey(attr)) {
pending.remove(attr);
} else {
pending[attr] = null;
}
notifyListeners();
return;
}
if (_attrCoversRange(attr, sel.start, sel.end)) {
removeAttr(attr, sel.start, sel.end);
} else {
spans.add(UStyleSpan(start: sel.start, end: sel.end, attr: attr));
}
normalize();
notifyListeners();
}