removeAllHtmlTags method

String removeAllHtmlTags(
  1. String htmlText
)

Implementation

String removeAllHtmlTags(String htmlText) {
  final exp = RegExp(
    '(<[^>]*>)',
    multiLine: true,
  );
  var newHtmlText = htmlText;
  exp.allMatches(htmlText).toList().forEach(
    (RegExpMatch regExpMatch) {
      newHtmlText = regExpMatch.group(0) == '<br>'
          ? newHtmlText.replaceAll(regExpMatch.group(0)!, '\n')
          : newHtmlText.replaceAll(regExpMatch.group(0)!, '');
    },
  );

  return newHtmlText;
}