ChatText class
Renders message text with chatx's markdown subset.
Supported syntax:
| Syntax | Result |
|---|---|
**bold** or __bold__ |
bold |
*italic* or _italic_ |
italic |
~~strike~~ |
strikethrough |
`code` |
inline code |
``` fences |
code block |
> quote |
block quote |
- item, 1. item |
lists |
# Heading |
heading |
[label](https://...) |
link |
||spoiler|| |
hidden until tapped |
https://..., www.... |
automatic link |
HTML is never interpreted. Links are filtered by linkPolicy; only allowed links are tappable and passed to onLinkTap.
ChatView uses this widget for every TextMessage. You can also use it
in your own builders.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ChatText
Constructors
-
ChatText(String text, {Key? key, TextStyle? style, TextStyle? linkStyle, TextStyle? codeStyle, Color? codeBackgroundColor, ValueChanged<
Uri> ? onLinkTap, ChatLinkPolicy linkPolicy = const ChatLinkPolicy(), InlineSpan? trailing, bool enableMarkdown = true, List<ChatUser> mentionableUsers = const [], ValueChanged<ChatUser> ? onMentionTap, TextStyle? mentionStyle, String? currentUserId, String? highlight, Color? highlightColor}) -
Creates a markdown text widget.
const
Properties
- codeBackgroundColor → Color?
-
Background of code spans and code blocks. Defaults to the text color
at 12% opacity.
final
- codeStyle → TextStyle?
-
Style merged on top of style for inline code and code blocks.
Defaults to a monospace font.
final
- currentUserId → String?
-
Mentions of this user are emphasized with a background.
final
- enableMarkdown → bool
-
When
false, text is shown verbatim (links are still detected).final - hashCode → int
-
The hash code for this object.
no setterinherited
- highlight → String?
-
Text to highlight, for example the current search query.
final
- highlightColor → Color?
-
Background of highlight matches.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- linkPolicy → ChatLinkPolicy
-
Filters which links are tappable.
final
- linkStyle → TextStyle?
-
Style merged on top of style for links. Defaults to an underline.
final
-
mentionableUsers
→ List<
ChatUser> -
Users that can be mentioned.
@Name(case-insensitive) is styled as a mention when it matches one of their names.final - mentionStyle → TextStyle?
-
Style merged on top of the text style for mentions. Defaults to bold.
final
-
onLinkTap
→ ValueChanged<
Uri> ? -
Called with the resolved Uri when the user taps an allowed link.
When
null, links are styled but not tappable.final -
onMentionTap
→ ValueChanged<
ChatUser> ? -
Called when the user taps a mention.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → TextStyle?
-
Base text style. Defaults to the ambient DefaultTextStyle.
final
- text → String
-
Raw markdown source.
final
- trailing → InlineSpan?
-
Inline content appended after the last paragraph, such as a streaming
caret.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ChatText> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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