Strings in Dart: Chapter Overview

Strings teaches you to work with text and time.

In this chapter, you will:

  • search, cut, change, split and join text with String methods
  • build long text quickly with StringBuffer, and handle emoji with runes
  • create dates with DateTime, and read parts like year and weekday
  • measure and add time with Duration

What each lesson covers:

  • Strings: How to create strings, put values inside them, compare, search, cut, change, split and join them, build long text with StringBuffer, and handle Unicode and emoji.
  • Date and Time: How to create DateTime values, read their parts, compare and subtract dates, add time with Duration, and convert dates to text and timestamps.

This chapter has 2 lessons. Plan on about 36 minutes, with 6 exercises to check what you learned. Every example is real Dart code: change it, run it again and compare the output, which is the fastest way to learn how each feature behaves.

Simple lesson: finish this chapter and you can build report cards, notices and timetables.

Lessons in this section

  1. Strings

    How to create strings, put values inside them, compare, search, cut, change, split and join them, build long text with StringBuffer, and handle Unicode and emoji.

    • Create strings and use interpolation
    • Search, extract and change text with string methods
    • Use StringBuffer, runes and Unicode
  2. Date and Time

    How to create DateTime values, read their parts, compare and subtract dates, add time with Duration, and convert dates to text and timestamps.

    • Create DateTime values and read their parts
    • Compare dates and work out the time between them
    • Use Duration to add and subtract time