Skip to main content

prefer_single_quotes

Unnecessary use of double quotes.

Description

#

The analyzer produces this diagnostic when a string literal uses double quotes (") when it could use single quotes (') without needing extra escapes and without hurting readability.

Example

#

The following code produces this diagnostic because the string literal uses double quotes but doesn't need to:

dart
void f(String name) {
  print("Hello $name");
}

Common fixes

#

Use single quotes in place of double quotes:

dart
void f(String name) {
  print('Hello $name');
}