Flutter widget to use Markup to easily create formatted Text. It supports bold, italic, underlined, links, color and custom tags.
- Support for custom tags
- Support for
TextSpan
MarkupText
is a wrapper for RichText
that simplifies the creation of text with mixed styles.
MarkupText("This is a (b)Markup(/b) example with (c deepPurple)a purple text(/c)")
Also, you can use MarkupTextSpan
to create a TextSpan
with mixed styles.
Text.rich(
MarkupTextSpan(
text: "This is a (b)Markup(/b) example with (c deepPurple)a purple text(/c)",
),
)
The style
parameter is used to define the default style of the text. It can be used to define the default font size, color, etc.
MarkupText(
"This is a (b)bold(/b) text (a https://flutter.dev)with a link(/a),"
" an (u)underlined(/u) word and (color ffff0000)colored(/color) words"
" (color FF7C4DFF)here(/color) and (color FF4CAF50)there(/color).",
style: MarkupTextStyle(
textStyle: const TextStyle(fontSize: 20),
),
),
The following tags are recognized by the widget
Use tag (b)..(/b) for bold text
MarkupText("This is a (b)bold(/b) text")
Use tag (i)..(/i) for italic text
MarkupText("This is an (i)italic(/i) text")
Use tag (u)..(/u) for underlined text
MarkupText("This is an (u)underlined(/u) text")
Use tag (a <url>)..(/a) to create links
MarkupText("(a http://example.com)This is a link(/a)")
Use tag (c <color>)..(/c) to create colored text
MarkupText("(c ffff0000)Colors from ARGB codes(/c)")