LabelElement constructor
LabelElement({
- required String text,
- required Offset anchor,
- Alignment defaultAlign = Alignment.center,
- required LabelStyle style,
- String? tag,
Creates a label element.
Implementation
LabelElement({
required this.text,
required Offset anchor,
Alignment defaultAlign = Alignment.center,
required LabelStyle style,
String? tag,
}) : super(
anchor: anchor,
defaultAlign: defaultAlign,
style: style,
tag: tag,
) {
_painter = TextPainter(
text: this.style.textStyle != null
? TextSpan(text: text, style: this.style.textStyle)
: this.style.span!(text),
textAlign: this.style.textAlign ?? TextAlign.start,
textDirection: this.style.textDirection ?? TextDirection.ltr,
textScaleFactor: this.style.textScaleFactor ?? 1.0,
maxLines: this.style.maxLines,
ellipsis: this.style.ellipsis,
locale: this.style.locale,
strutStyle: this.style.strutStyle,
textWidthBasis: this.style.textWidthBasis ?? TextWidthBasis.parent,
textHeightBehavior: this.style.textHeightBehavior,
);
_painter.layout(
minWidth: this.style.minWidth ?? 0.0,
maxWidth: this.style.maxWidth ?? double.infinity,
);
paintPoint = getBlockPaintPoint(rotationAxis!, _painter.width,
_painter.height, this.style.align ?? this.defaultAlign);
}