setDecorationLayer method
bool
setDecorationLayer(
- String layerKey,
- Iterable<
TextDecorationRange> decorations, { - int priority = textDefaultDecorationLayerPriority,
Implementation
bool setDecorationLayer(
String layerKey,
Iterable<TextDecorationRange> decorations, {
int priority = textDefaultDecorationLayerPriority,
}) {
_refreshDocumentSnapshot();
final normalized = decorations
.map((range) => range.normalized().clamp(_document.length))
.where((range) => !range.isEmpty)
.toList(growable: false);
final existingLayer = _decorationLayers[layerKey];
if (normalized.isEmpty) {
if (existingLayer == null) {
return false;
}
_decorationLayers.remove(layerKey);
_rebuildDecorations();
return true;
}
if (existingLayer != null &&
existingLayer.priority == priority &&
_decorationListsEqual(existingLayer.decorations, normalized)) {
return false;
}
_decorationLayers[layerKey] = (
decorations: normalized,
order: existingLayer?.order ?? _nextDecorationLayerOrder++,
priority: priority,
);
_rebuildDecorations();
return true;
}