Strings and string interpolation
A String
is simply a variable that holds human-readable text. The reason why they're called strings instead of text has more to do with history than practicality. From a computer's perspective, a String
is actually a list of integers. Each integer represents a character.
For example, the number U+0041
(Unicode notation, 65 in decimal notation) is the letter A. These numbers are stringed together to create text.
In this recipe, we will continue with the console application in order to define and work with strings.
Getting ready
- To follow along with this recipe, you should write this code in DartPad (https://dartpad.dev/). Remove any content inside the main() method.
How to do it...
Just like in the previous recipe, you are going to create a “hub” function. Inside it, every sub-function will show a different way of using strings:
- Type in the following code and use it as the hub for all the other string examples:
void stringPlayground...