toPlainText static method

String toPlainText(
  1. String? html
)

Strips all tags, returning the readable text of html.

Implementation

static String toPlainText(String? html) {
  final List<UEditorBlock> blocks = parse(html);
  final String text = blocks
      .map((UEditorBlock b) => b.isText ? b.controller!.text : (b.type == UBlockType.table ? (b.table?.rows.map((List<String> r) => r.join(" ")).join("\n") ?? "") : ""))
      .where((String s) => s.isNotEmpty)
      .join("\n");
  for (final UEditorBlock b in blocks) {
    b.dispose();
  }
  return text;
}