escape function Null safety
- String string
Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities.
Implementation
String escape(String string) {
return string
.replaceAll(RegExp(r'&'), '&')
.replaceAll(RegExp(r'<'), '<')
.replaceAll(RegExp(r'>'), '>')
.replaceAll(RegExp(r'"'), '"')
.replaceAll(RegExp(r"'"), ''');
}