Escape strings before writing dart literals

This commit is contained in:
Simon Binder 2019-06-29 13:55:13 +02:00
parent 646987ad69
commit d930664581
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
1 changed files with 2 additions and 1 deletions

View File

@ -1,3 +1,4 @@
String asDartLiteral(String value) {
return "'$value'"; // todo proper escaping
final escaped = value.replaceAll("'", "\\'").replaceAll('\n', '\\n');
return "'$escaped'";
}