Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String with single or double quotes? #19

Open
SimonLab opened this issue Nov 25, 2020 · 2 comments
Open

String with single or double quotes? #19

SimonLab opened this issue Nov 25, 2020 · 2 comments
Labels
discuss enhancement New feature or request

Comments

@SimonLab
Copy link
Member

You can represent a string with either single quotes or double quotes without any difference.

const hello1 = "hello";
const hello2 = 'hello';
hello1 == hello2; //true

To escape specific characters in a string use \

Dart style guide let you decide which one you prefer to use, just be consistent.
Flutter style guide recommend to use single quote: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#prefer-single-quotes-for-strings

ref:

@nelsonic
Copy link
Member

@SimonLab good question, thanks for opening this issue. 👍

We should use whatever the "Effective Dart" Linter enforces.
e.g: https://dart.dev/guides/language/effective-dart/usage#prefer-using-interpolation-to-compose-strings-and-values
(all the examples use single quotes)

And if you really want to be strict, use the "Pedantic" linter: https://pub.dev/packages/pedantic
which is what they use at Google.

See: https://medium.com/flutter-community/effective-code-in-your-flutter-app-from-the-beginning-e597444e1273

But yeah, the tl;dr is: single quotes for strings in Dart/Flutter. ✅

@siraajul
Copy link

to quote something inside string we need to use double quote 'Hello My Name is "Sirajul" ';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants