AttributedSpans class

A set of spans, each with an associated Attribution, that take up some amount of space in a discrete range.

AttributedSpans are useful when implementing attributed text for the purpose of markup and styling.

You can think of AttributedSpans like a set of lanes. Each lane may be occupied by some series of spans for a particular attribute:


An attribution can be any subclass of Attribution. Based on the type of Attribution that is used, two Attributions might occupy the same lane or different lanes. For example, any two NamedAttributions occupy the same lane if-and-only-if the two Attributions have the same name, like "bold".

Each attributed span is represented by two SpanMarkers, one with type SpanMarkerType.start and one with type SpanMarkerType.end.

Spans with equivalent Attributions cannot overlap each other, but spans with different Attributions can overlap each other.

Constructors

AttributedSpans({List<SpanMarker>? attributions})
Constructs an AttributedSpans with the given attributions.

Properties

hashCode int
The hash code for this object.
no setteroverride
markers Iterable<SpanMarker>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addAt({required AttributedSpans other, required int index}) → void
Pushes back all the spans in other to index, and then appends the other spans to this AttributedSpans.
addAttribution({required Attribution newAttribution, required int start, required int end, bool autoMerge = true, bool overwriteConflictingSpans = true}) → void
Applies the newAttribution from start to end, inclusive.
collapseSpans({required int contentLength}) List<MultiAttributionSpan>
Combines all spans of different types into a single list of spans that contain multiple types per segment.
contractAttributions({required int startOffset, required int count}) → void
Changes spans in this AttributedSpans by cutting out the region from startOffset to startOffset + count, exclusive.
copy() AttributedSpans
Returns a copy of this AttributedSpans.
copyAttributionRegion(int startOffset, [int? endOffset]) AttributedSpans
Returns of a copy of this AttributedSpans between startOffset and endOffset.
expandAttributionToSpan({required Attribution attribution, required int offset}) AttributionSpan
Calculates and returns the full AttributionSpan, which contains the given attribution at the given offset.
getAllAttributionsAt(int offset) Set<Attribution>
Returns all attributions for spans that cover the given offset.
getAttributedRange(Set<Attribution> attributions, int offset) SpanRange
Returns the range about offset, which is attributed with all given attributions.
getAttributionSpansInRange({required AttributionFilter attributionFilter, required int start, required int end, bool resizeSpansToFitInRange = false}) Set<AttributionSpan>
Returns spans for each attribution that (at least partially) appear between start and end, inclusive, as selected by attributionFilter.
getMatchingAttributionsWithin({required Set<Attribution> attributions, required int start, required int end}) Set<Attribution>
Finds and returns all Attributions in this AttributedSpans that match any of the given attributions.
hasAttributionAt(int offset, {Attribution? attribution}) bool
Returns true if the given offset has the given attribution.
hasAttributionsWithin({required Set<Attribution> attributions, required int start, required int end}) bool
Returns true if this AttributedSpans contains at least one unit of attribution for each of the given attributions within the given range (inclusive).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pushAttributionsBack(int offset) → void
Changes all spans in this AttributedSpans by pushing them back by offset amount.
removeAttribution({required Attribution attributionToRemove, required int start, required int end}) → void
Removes attributionToRemove between start and end, inclusive.
toggleAttribution({required dynamic attribution, required int start, required int end}) → void
If ALL of the units between start and end, inclusive, contain the given attribution, that attribution is removed from those units. Otherwise, all of the units between start and end, inclusive, are assigned the attribution.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override