String Literals and Quotes
Single, double, and triple-quoted strings.
String Literals and Quotes is a free Dart Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Dart Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What a String Literal Is
A string literal is text you type directly into your code, wrapped in quotes so Dart treats it as words, not commands.
var greeting = 'Hello, Dart!';Single Quotes Work Great
The most common way to write text in Dart is with single quotes. They are clean, quick, and the style most Dart code uses.
var name = 'Ada';Double Quotes Are Equal
Dart also accepts double quotes for strings. They behave exactly like single quotes, so the choice is mostly about style. 🙂
var city = "Berlin";Pick One and Stay Consistent
Both quote styles are valid, but good code stays consistent. Most teams pick single quotes and use them everywhere unless there is a reason not to.
Quotes Inside Quotes
If your text contains an apostrophe, wrap it in double quotes so Dart does not think the string ended early.
var note = "It's a sunny day";The Other Way Around
The same trick flips: if your text contains double quotes, wrap the whole string in single quotes to keep it readable.
var quote = 'She said "hi" softly';Escaping With a Backslash
The backslash escapes a quote so it counts as a character, not an ending. Use it when you cannot easily switch quote styles.
var msg = 'It\'s mine';Empty Strings Are Valid
An empty string is just two quotes with nothing between them. It is a real value, often used as a starting point before you add text.
var blank = '';Triple Quotes for Long Text
For text spanning several lines, Dart offers triple quotes. They let you write paragraphs without escaping every line break.
var poem = '''Roses are red
Violets are blue''';Strings Have a Type
Every literal you write is a String, Dart's built-in type for text. You can store it, pass it around, and inspect its length.
String label = 'price';Joining Strings With Plus
You can glue two strings together with the plus operator. The result is a brand-new string made of both pieces in order.
var full = 'Dart' + ' rocks';Quick Check
Your text contains an apostrophe. What is the cleanest way to write it?
Recap: Quoting Text
You learned that string literals use single, double, or triple quotes. Match your quote style to the text inside, and stay consistent. 🎉
Frequently asked questions
Is the “String Literals and Quotes” lesson free?
Yes — the full text of “String Literals and Quotes” is free to read here on the web, and the Dart Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Dart Academy course, upgrade to CoddyKit PRO.
What will I learn in “String Literals and Quotes”?
Single, double, and triple-quoted strings. You practise Dart Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Dart Academy?
No prior experience is required. Dart Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “String Literals and Quotes” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Dart Academy lesson?
Yes. Every Dart Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- String Literals and Quotes
- String Interpolation With the Dollar Sign
- Multi-line and Raw Strings
- Everyday String Methods