TextRenderBox constructor
TextRenderBox({
- required String text,
- required SmartTextStyle normalStyle,
- required SmartTextStyle boldStyle,
- required SmartTextStyle italicStyle,
- required SmartTextStyle linkStyle,
- required SmartTextStyle hashtagsStyle,
- required TextDirection textDirection,
- required TextAlign textAlign,
- TextOverflow? overflow,
- void onLinkTap(
- String url
- void onHashtagTap(
- String tag
- int? maxLines,
Creates a TextRenderBox.
All parameters except overflow, onLinkTap, onHashtagTap, and maxLines
are required.
Parameters:
text: The text content to rendernormalStyle: Style applied to regular textboldStyle: Style applied to bold text and its formatting symbolitalicStyle: Style applied to italic text and its formatting symbollinkStyle: Style applied to detected linkshashtagsStyle: Style applied to hashtagstextDirection: Direction of text flow (LTR or RTL)textAlign: How text should be aligned (left, right, center, etc.)overflow: How to handle text that doesn't fit (ellipsis, clip, fade, visible)onLinkTap: Callback fired when a link is tapped, receives the URL stringonHashtagTap: Callback fired when a hashtag is tapped, receives the tag stringmaxLines: Maximum number of lines to display, null for unlimited
Implementation
TextRenderBox({
required String text,
required SmartTextStyle normalStyle,
required SmartTextStyle boldStyle,
required SmartTextStyle italicStyle,
required SmartTextStyle linkStyle,
required SmartTextStyle hashtagsStyle,
required TextDirection textDirection,
required TextAlign textAlign,
TextOverflow? overflow,
void Function(String url)? onLinkTap,
void Function(String tag)? onHashtagTap,
int? maxLines,
}) : _text = text,
_normalStyle = normalStyle,
_boldStyle = boldStyle,
_italicStyle = italicStyle,
_linkStyle = linkStyle,
_hashtagsStyle = hashtagsStyle,
_textAlign = textAlign,
_textDirection = textDirection,
_overflow = overflow,
_maxLines = maxLines,
_onLinkTap = onLinkTap,
_onHashtagTap = onHashtagTap,
_textPainter = TextPainter(
textDirection: textDirection,
textAlign: textAlign,
maxLines: maxLines,
ellipsis: overflow == TextOverflow.ellipsis ? '...' : null,
);