processHtml static method

String processHtml({
  1. required String html,
  2. bool processInputHtml = true,
  3. bool processNewLineAsBr = false,
})

Helper function to process input html

Implementation

static String processHtml({
  required String html,
  bool processInputHtml = true,
  bool processNewLineAsBr = false,
}) {
  if (processInputHtml) {
    html = kIsWeb
        ? html.replaceAll('\r', '').replaceAll('\r\n', '')
        : html
            .replaceAll("'", r"\'")
            .replaceAll('"', r'\"')
            .replaceAll('\r', '')
            .replaceAll('\r\n', '');
  }
  if (processNewLineAsBr) {
    html = html.replaceAll('\n', '<br/>').replaceAll('\n\n', '<br/>');
  } else {
    html = html.replaceAll('\n', '').replaceAll('\n\n', '');
  }
  return html;
}