TextMessage class

Widget that renders text messages with support for markdown, link previews, and emoji enlargement. This is the most common message type, handling plain text with advanced formatting capabilities including clickable links, preview cards for URLs, and special handling for emoji-only messages.

Inheritance

Constructors

TextMessage({Key? key, required EmojiEnlargementBehavior emojiEnlargementBehavior, required bool hideBackgroundOnEmojiMessages, required TextMessageModel message, Widget nameBuilder(ChatUser)?, void onPreviewDataFetched(TextMessageModel, PreviewData)?, TextMessageOptions options = const TextMessageOptions(), required bool showName, required bool usePreviewData, String? userAgent})
Creates a text message widget with comprehensive formatting and interaction options. Supports link previews, custom styling, emoji enlargement, and user name display.
const

Properties

emojiEnlargementBehavior → EmojiEnlargementBehavior
Controls how emoji-only messages are displayed (never, single, multi). When set to enlarge emojis, text messages containing only emojis are rendered larger.
final
hashCode → int
The hash code for this object.
no setterinherited
hideBackgroundOnEmojiMessages → bool
Whether to hide the message bubble background for emoji-only messages. This creates a cleaner look for emoji reactions and expressions.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
message → TextMessageModel
The text message data containing the actual text content and metadata. Includes text, optional preview data, author info, and timestamps.
final
nameBuilder → Widget Function(ChatUser)?
Optional custom builder for rendering user names above messages. Allows dynamic user info fetching and custom name styling based on user data. If null, uses the default UserName widget.
final
onPreviewDataFetched → void Function(TextMessageModel, PreviewData)?
Callback invoked when link preview data is successfully fetched from a URL. Used to update the message model with preview data for caching and display.
final
options → TextMessageOptions
Configuration options controlling text behavior, link handling, and interactions. Includes settings for text selection, link callbacks, and preview tap behavior.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showName → bool
Whether to display the sender's name above the message text. Primarily useful in group chats to identify message authors.
final
usePreviewData → bool
Whether to automatically fetch and display previews for URLs found in the text. When enabled, URLs are parsed and preview cards are shown below the message.
final
userAgent → String?
User agent string sent with HTTP requests when fetching link preview data. Some websites require specific user agents for proper preview generation.
final

Methods

build(BuildContext context) → Widget
Builds the complete text message widget with conditional link preview support. Determines whether to show link previews, emoji enlargement, and appropriate styling.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

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