Reputation: 20607
Code:
import 'package:html/parser.dart';
class HtmlUtil {
String? toPlainTxt(String htmlString) {
final document = parse(htmlString);
final parsedString = parse(document.body?.text).documentElement?.text;
return parsedString;
}
}
Input:
<p>Hello<br/><span style="color:#f00">This is colorful</span></p>
Output:
HelloThis is colorful
Expected:
Hello\nThis is colorful
What am I doing wrong?
Upvotes: 0
Views: 31