extended rich text
the easy rich text widget provides an easy way to use richtext when you want to use specific style for specific word.
this widget split string into multiple textspan by defining a <pattern,textstyle> map;
getting started
installing:
dependencies:
easy_rich_text: '^0.1.0'
usage:
string str = "this is a easyrichtext example. i want blue font. i want bold font. i want italic font. i want whole sentence bold." ;
simple example:
easyrichtext(
text: str,
patternmap: {
' bold ': textstyle(fontweight: fontweight.bold),
'i want whole sentence bold.': textstyle(fontweight: fontweight.bold),
' blue ': textstyle(fontweight: fontweight.bold, color: colors.blue)
},
)
default style:
easyrichtext(
text: str,
defaultstyle: textstyle(color: colors.grey),
patternmap: {
' bold ': textstyle(fontweight: fontweight.bold),
' blue ': textstyle(fontweight: fontweight.bold, color: colors.blue),
' italic ': textstyle(fontstyle: fontstyle.italic,),
},
),
all richtext properties accessible: textalign, maxlines, overflow, etc.
easyrichtext(
text: str,
defaultstyle: textstyle(
color: colors.grey,
),
patternmap: {
' bold ': textstyle(fontweight: fontweight.bold),
'i want whole sentence bold.': textstyle(fontweight: fontweight.bold),
' blue ': textstyle(fontweight: fontweight.bold, color: colors.blue),
' italic ': textstyle(fontstyle: fontstyle.italic,),
},
textalign: textalign.justify,
maxlines: 1,
overflow: textoverflow.ellipsis,
),
Comments are closed.