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