StacText class

A Stac widget for displaying text with customizable styling and layout.

This widget corresponds to Flutter's Text widget and supports rich text formatting, alignment, overflow handling, and accessibility features. It can display both simple text and rich text with multiple text spans.

{@tool snippet} Dart Example:

StacText(
  data: 'Hello, World!',
  style: StacTextStyle(
    fontSize: 18.0,
    fontWeight: StacFontWeight.bold,
    color: StacColors.blue,
  ),
  textAlign: StacTextAlign.center,
  maxLines: 2,
  overflow: StacTextOverflow.ellipsis,
)

{@end-tool}

{@tool snippet} JSON Example:

{
  "type": "text",
  "data": "Hello, World!",
  "style": {
    "fontSize": 18.0,
    "fontWeight": "bold",
    "color": "#2196F3"
  },
  "textAlign": "center",
  "maxLines": 2,
  "overflow": "ellipsis"
}

{@end-tool}

Inheritance
Annotations
  • @JsonSerializable()

Constructors

StacText.new({required String data, List<StacTextSpan> children = const [], StacTextStyle? style, StacTextAlign? textAlign, StacTextDirection? textDirection, bool? softWrap, StacTextOverflow? overflow, double? textScaleFactor, int? maxLines, String? semanticsLabel, StacTextWidthBasis? textWidthBasis, StacColor? selectionColor})
Creates a text widget with the given text data and optional styling.
StacText.fromJson(Map<String, dynamic> json)
Creates a StacText from a JSON map.
factory

Properties

children List<StacTextSpan>
Additional text spans for rich text formatting.
final
data String
The text to display.
final
hashCode int
The hash code for this object.
no setterinherited
jsonData Map<String, dynamic>?
Raw JSON data for this widget
finalinherited
maxLines int?
An optional maximum number of lines for the text to span.
final
overflow StacTextOverflow?
How visual overflow should be handled.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectionColor StacColor?
The color to use when painting the selection.
final
semanticsLabel String?
An alternative semantic label for this text.
final
softWrap bool?
Whether the text should break at soft line breaks.
final
style StacTextStyle?
The text style to apply to the text.
final
textAlign StacTextAlign?
How the text should be aligned horizontally.
final
textDirection StacTextDirection?
The directionality of the text.
final
textScaleFactor double?
The number of font pixels for each logical pixel.
final
textWidthBasis StacTextWidthBasis?
The strategy to use when calculating the width of the text.
final
type String
The type of the widget
no setteroverride

Methods

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

Operators

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