getFormattedText static method
This method get string and convert it to a list of TextObj
use a list into RichText widget to show a whole text
get the output of _addSpacerInContent
and convert it list of TextObj
output of _addSpacerInContent
= "uniqueSpacer#HellouniqueSpacer Mohamed ,this is my website uniqueSpacerhttps://www.mywebsite.comuniqueSpacer"
convert it to normal list #Hello,Mohamed ,this is my website,https://www.mywebsite.com
convert normal list to list of TextObj
Implementation
static Future<List<TextObj>> getFormattedText(String str) async {
List<TextObj> texts = <TextObj>[];
String newContent = str;
for (var regExp in _regs) {
newContent = _addSpacerInContent(newContent, regExp);
}
List<String> separateContent = newContent.split(uniqueSpacer);
//Remove any field contain empty space, if found
separateContent.removeWhere((element) => element == '');
for (var text in separateContent) {
TextType _type = _textType(text);
texts.add(TextObj(
type: _type,
text: text,
));
}
return texts;
}