compose method
void
compose(
- Delta change, {
- TextSelection? selection,
- ChangeSource source = ChangeSource.remote,
Composes change
into document managed by this controller.
This method does not apply any adjustments or heuristic rules to
provided change
and it is caller's responsibility to ensure this change
can be composed without errors.
If composing this change fails then this method throws ComposeError
.
Implementation
void compose(Delta change,
{TextSelection? selection, ChangeSource source = ChangeSource.remote}) {
if (change.isNotEmpty) {
document.compose(change, source);
}
if (selection != null) {
_updateSelectionSilent(selection, source: source);
} else {
// Transform selection against the composed change and give priority to
// current position (force: false).
final base =
change.transformPosition(_selection.baseOffset, force: false);
final extent =
change.transformPosition(_selection.extentOffset, force: false);
selection = _selection.copyWith(baseOffset: base, extentOffset: extent);
if (_selection != selection) {
_updateSelectionSilent(selection, source: source);
}
}
notifyListeners();
}