htmlText property
String
htmlText
Implementation
String get htmlText {
String html = '';
for (int i = 0; i < this.text.length; i++) {
TextStyle _previous = i - 1 >= 0 ? (styles[i - 1] ?? this.defaultTextStyle) : defaultTextStyle;
TextStyle _current = styles[i] ?? defaultTextStyle;
if (_previous.fontWeight != _current.fontWeight) {
if (_previous.fontWeight == FontWeight.w400)
html += '<b>';
else
html += '</b>';
}
if (_previous.fontStyle != _current.fontStyle) {
if (_previous.fontStyle == FontStyle.normal)
html += '<i>';
else
html += '</i>';
}
if (_previous.decoration != _current.decoration) {
if (_previous.decoration == TextDecoration.none)
html += '<u>';
else
html += '</u>';
}
html += this.text[i];
}
TextStyle _lastOne = this.styles[this.text.length - 1] ?? defaultTextStyle;
if (_lastOne.fontWeight == FontWeight.w700) html += '</b>';
if (_lastOne.fontStyle == FontStyle.italic) html += '</i>';
if (_lastOne.decoration == TextDecoration.underline) html += '</u>';
return html.replaceAll('\n', '<br>');
}