escape function
replace <
, >
, &
, '
and "
with HTML entities
Implementation
String escape(String str) => str
.replaceAll(RegExp('&'), '&')
.replaceAll(RegExp('"'), '"')
.replaceAll(RegExp("'"), ''')
.replaceAll(RegExp('<'), '<')
.replaceAll(RegExp('>'), '>');