StacTextSpan class

A Stac representation of an immutable span of text.

This class defines a piece of text with associated styling and optional child spans for rich text formatting.

{@tool snippet} Dart Example:

StacTextSpan(
  text: 'Hello ',
  style: StacTextStyle(fontWeight: StacFontWeight.bold),
  children: [
    StacTextSpan(text: 'World', style: StacTextStyle(color: StacColors.blue)),
  ],
)

{@end-tool}

{@tool snippet} JSON Example:

{
  "text": "Hello ",
  "style": {"fontWeight": "bold"},
  "children": [
    {"text": "World", "style": {"color": "#2196F3"}}
  ]
}

{@end-tool}

Implemented types
Annotations
  • @JsonSerializable.new()

Constructors

StacTextSpan({String? text, StacTextStyle? style, List<StacTextSpan> children = const [], Map<String, dynamic>? onTap})
Creates a text span with optional text, style, children, and tap handler.
StacTextSpan.fromJson(Map<String, dynamic> json)
Creates a StacTextSpan from a JSON map.
factory

Properties

children → List<StacTextSpan>
Additional text spans to include as children.
final
hashCode → int
The hash code for this object.
no setterinherited
onTap → Map<String, dynamic>?
Action to perform when this text span is tapped.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
style → StacTextStyle?
The style to apply to the text in this span.
final
text → String?
The text content of this span.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Converts this element to a JSON map
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited