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:
Bold : {xxxx} {xxxxx} Italics : {xxxxxxxx} Link : {xxxxx}
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
toindex
, and then appends theother
spans to this AttributedSpans. -
addAttribution(
{required Attribution newAttribution, required int start, required int end, bool autoMerge = true, bool overwriteConflictingSpans = true}) → void -
Applies the
newAttribution
fromstart
toend
, 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
tostartOffset + 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
andendOffset
. -
expandAttributionToSpan(
{required Attribution attribution, required int offset}) → AttributionSpan -
Calculates and returns the full AttributionSpan, which contains the
given
attribution
at the givenoffset
. -
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 givenattributions
. -
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
andend
, inclusive, as selected byattributionFilter
. -
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 givenoffset
has the givenattribution
. -
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 givenattributions
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
betweenstart
andend
, inclusive. -
toggleAttribution(
{required dynamic attribution, required int start, required int end}) → void -
If ALL of the units between
start
andend
, inclusive, contain the givenattribution
, that attribution is removed from those units. Otherwise, all of the units betweenstart
andend
, inclusive, are assigned theattribution
. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override