rich_text_composer

Last updated:

0 purchases

rich_text_composer Image
rich_text_composer Images
Add to Cart

Description:

rich text composer

Rich text composer #
Sometimes RichText composing is easier with pattern matching. RichTextComposer turns composition like this:
RichText(
text: TextSpan(
children: [
TextSpan("The forecast for today is ", style: TextStyle(color: Colors.black)),
TextSpan(weatherType, style: TextStyle(fontWeight: FontWeight.bold)),
TextSpan(" with a high of ", style: TextStyle(color: Colors.black)),
TextSpan(temperatureMax, style: TextStyle(color: Colors.red)),
]
)
)
copied to clipboard
into this:
RichTextComposer(
text: "The forecast for today is @type with a high of @high",
richTextBuilders: [
RichTextPatternBuilder(
pattern: RegExp('@weatherType'),
builder: (
text, {
required endIndex,
required matchIndex,
required startIndex,
}) {
return TextSpan(text: weatherType, style: TextStyle(fontWeight: FontWeight.bold));
},
),
RichTextPatternBuilder(
pattern: RegExp('@high'),
builder: (
text, {
required endIndex,
required matchIndex,
required startIndex,
}) {
return TextSpan(text: weatherType, style: TextStyle(color: Colors.red));
},
),
],
plainTextBuilder: (text) => TextSpan(
text: text,
style: TextStyle(color: Colors.black)
),
)
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.