Skip to main content

use_raw_strings

Use a raw string to avoid using escapes.

Description

#

The analyzer produces this diagnostic when a string literal containing escapes, and no interpolations, could be marked as being raw in order to avoid the need for the escapes.

Example

#

The following code produces this diagnostic because the string contains escaped characters that wouldn't need to be escaped if the string is made a raw string:

dart
var s = 'A string with only \\ and \$';

Common fixes

#

Mark the string as being raw and remove the unnecessary backslashes:

dart
var s = r'A string with only \ and $';