diff --git a/embed/lib/src/literal/dart_literals.dart b/embed/lib/src/literal/dart_literals.dart index 4610e13..636943b 100644 --- a/embed/lib/src/literal/dart_literals.dart +++ b/embed/lib/src/literal/dart_literals.dart @@ -72,7 +72,7 @@ class StringLiteral extends DartLiteral { @override String toString() { - final literal = value.replaceAll('"', r'\"'); + final literal = value.replaceAll('"', r'\"').replaceAll(r'$', r'\$'); return '"$literal"'; } } diff --git a/embed/test/literal/literal_embedding_generator_test.dart b/embed/test/literal/literal_embedding_generator_test.dart index 2534850..1f8eeed 100644 --- a/embed/test/literal/literal_embedding_generator_test.dart +++ b/embed/test/literal/literal_embedding_generator_test.dart @@ -243,3 +243,14 @@ const _$mapPattern = {"a": 0, "b": 0.0, "c": true}; """, ) Map? mapPattern; + +@TestEmbedLiteral( + extension: "json", + content: r""" +{ "dollar": "$" } +""", + shouldGenerate: r""" +const _$stringLiteralsDollar = (dollar: "\$"); +""", +) +var stringLiteralsDollar;