With following code snippet, you'll be able to trim html tags from string in dart programming language.
import 'dart:developer';
class Utilities {
static String formatTime(int seconds) {
return '${(Duration(seconds: seconds))}'.split('.')[0].padLeft(8, '0');
}
static String removeAllHtmlTags(String htmlText) {
RegExp exp = RegExp(
r"<[^>]*>",
multiLine: true,
caseSensitive: true
);
return htmlText.replaceAll(exp, '');
}
}
// example usage
String value = "<h1>This is heading1.</h1>";
log("removed tags - ${Utilities(). removeAllHtmlTags(value)}");
Upvote if it helps :)