getText method

Future<String> getText()

getText method is used to get the html string from the editor To avoid getting empty html tags, we are validating the html string if it doesn't contain any text, the method will return empty string instead of empty html tag

Implementation

Future<String> getText() async {
  try {
    String? text = await _editorKey?.currentState?._getHtmlFromEditor();
    if (text == '<p><br></p>') {
      return text!.replaceAll('<p><br></p>', '');
    }
    return text ?? '';
  } catch (e) {
    return "";
  }
}