activeValue method

Object? activeValue(
  1. UInlineAttr attr
)

The value of a value-attribute at the current selection, or null when the selection is not uniformly covered by it.

Implementation

Object? activeValue(UInlineAttr attr) {
  final TextSelection sel = selection;
  if (!sel.isValid) return null;
  if (pending.containsKey(attr)) return pending[attr];
  final int probe = sel.isCollapsed ? sel.start - 1 : sel.start;
  if (probe < 0) return null;
  for (final UStyleSpan sp in spans) {
    if (sp.attr == attr && probe >= sp.start && probe < sp.end) return sp.value;
  }
  return null;
}