escape function
Implementation
String escape(String input) {
const entityMap = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
'/': '/',
};
final pattern = RegExp('[&<>"\'\\/]');
return input.replaceAllMapped(pattern, (match) {
final char = match[0]!;
return entityMap[char] ?? char;
});
}