TextRenderBox constructor

TextRenderBox({
  1. required String text,
  2. required SmartTextStyle normalStyle,
  3. required SmartTextStyle boldStyle,
  4. required SmartTextStyle italicStyle,
  5. required SmartTextStyle linkStyle,
  6. required SmartTextStyle hashtagsStyle,
  7. required TextDirection textDirection,
  8. required TextAlign textAlign,
  9. TextOverflow? overflow,
  10. void onLinkTap(
    1. String url
    )?,
  11. void onHashtagTap(
    1. String tag
    )?,
  12. int? maxLines,
})

Creates a TextRenderBox.

All parameters except overflow, onLinkTap, onHashtagTap, and maxLines are required.

Parameters:

  • text: The text content to render
  • normalStyle: Style applied to regular text
  • boldStyle: Style applied to bold text and its formatting symbol
  • italicStyle: Style applied to italic text and its formatting symbol
  • linkStyle: Style applied to detected links
  • hashtagsStyle: Style applied to hashtags
  • textDirection: 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 string
  • onHashtagTap: Callback fired when a hashtag is tapped, receives the tag string
  • maxLines: 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,
      );