escapeString function
Implementation
String escapeString(String text, [bool quote = true]) {
text = text.replaceAll('\\', r'\\');
text = text.replaceAll('\b', r'\b');
text = text.replaceAll('\f', r'\f');
text = text.replaceAll('\n', r'\n');
text = text.replaceAll('\r', r'\r');
text = text.replaceAll('\t', r'\t');
text = text.replaceAll('\v', r'\v');
text = text.replaceAll('\'', '\\\'');
text = text.replaceAll('\$', r'\$');
if (!quote) {
return text;
}
return '\'$text\'';
}