Closed vishal-android-freak closed 2 years ago
try matchBuilder
EasyRichText(
"TEST *bold font*. test *boldfont*.",
patternList: [
EasyRichTextPattern(
targetString: '(\\*)(.*?)(\\*)',
matchBuilder: (BuildContext context, RegExpMatch match) {
return TextSpan(
text: match[0].replaceAll('*', ''),
style: TextStyle(fontWeight: FontWeight.bold),
);
},
),
],
),
im trying to get bold and italic and underline formatting like WhatsApp and im using the following but im getting no result
patternList: [ ///bold font EasyRichTextPattern( targetString: '(\)(.?)(\)', matchBuilder: (BuildContext context, RegExpMatch match) { print(match[0]); return TextSpan( text: match[0].replaceAll('', ''), style: TextStyle(fontWeight: FontWeight.bold), ); }, ),
///italic font
EasyRichTextPattern(
targetString: '(\_)(.*?)(\_)',
matchBuilder:
(BuildContext context, RegExpMatch match) {
print(match[0]);
return TextSpan(
text: match[0].replaceAll('_', ''),
style:
TextStyle(fontStyle: FontStyle.italic),
);
},
),
],
the other text turns black idk why when default color is white could you help me out
try matchBuilder
EasyRichText( "TEST *bold font*. test *boldfont*.", patternList: [ EasyRichTextPattern( targetString: '(\\*)(.*?)(\\*)', matchBuilder: (BuildContext context, RegExpMatch match) { return TextSpan( text: match[0].replaceAll('*', ''), style: TextStyle(fontWeight: FontWeight.bold), ); }, ), ], ),
If your target string can be multiline, you can use this pattern:
(\\*)((.|\\n)*?)(\\*)
Only difference is that this one also includes new line character between your marks *
Hey, I want the users to define a bold ord like similar to how whatsapp does it. How can I define a dynamic target string because users can type any word between and I want the asterisks to get replaced and the words between them should become bold.
Any idea how we can achieve this?