Skip to main content
← Chapter 1: The Dart Basics Lesson 1.4

Strings in Dart

Recommended time: 4 days

Strings can be found everywhere. String manipulation is one of the most important programming tasks that we perform on a daily basis. As a result, it is critical that you comprehend this lesson. A Dart string is a sequence of UTF-16 code units. In Dart, string values can be represented by single, double, or triple quotes. Single or double quotes are used to represent single line strings. Multi-line strings are represented by triple quotes. You can insert values into a string with interpolation, for example 'Hello $name' or 'Total: ${price * 2}'.

Projects

1. Count number of words in given text

Given an input paragraph of text, count and print the number of words in that text.

  • Receive a paragraph of text as user input
  • Count the number of words
  • Print the number of words

2. Concatenate strings

Write a program that uses string concatenation to combine several strings into a single string, and then prints the result to the console.

Note: for completing projects in this lesson, you might have to look at a few resources in the next two lessons as well (operators and control flow).

Resources