Dart is an easy-to-learn yet powerful programming language. As one of the most versatile languages on the market today, you can use it to write anything from command-line apps and backend servers to native applications for Android, iOS, web, Mac, Windows and Linux. Dart was the language of choice for Flutter, and the two have seen an exponential rise in popularity in recent years.
Dart Apprentice: Beyond the Basics is the second of a two-book series that will teach you all the important concepts you need to master this language. Follow along with the clearly and thoroughly explained concepts, and you’ll be building Dart applications in no time.
Before You Begin
This section tells you a few things you need to know before you get started, such as what you’ll need for hardware and software, where to find the project files for this book, and more.
Dart Apprentice: Beyond the Basics
In this chapter, you’ll go beyond a basic understanding of strings and learn how to modify them to your needs. This includes basic tasks like capitalization, adding or removing whitespace, splitting and joining, and replacing text in a string. You’ll also learn to validate strings and extract text using regular expressions.
Anonymous functions are functions without names. You can assign them to variables and pass them to and from other functions. In this chapter, you’ll learn how to use anonymous functions with collections and as callback handlers.
In “Dart Apprentice: Fundamentals” you learned about classes. This chapter will take you beyond that to create a hierarchy of classes that share some base functionality. This is done through extending classes, which creates a parent-child or superclass-subclass relationship.
Abstract classes describe the general characteristics and behavior of a class without specifying the exact way that class is implemented. They’re a key foundation to implementing the interfaces you’ll learn about later.
Interfaces are similar to abstract classes in that they let you define the behavior you expect for all classes that implement the interface. They’re a means of hiding the implementation details of the concrete classes from the rest of your code.
Mixins are an interesting feature of Dart that you might not be familiar with, even if you know other programming languages. They’re a way to reuse methods or variables among otherwise unrelated classes.
Extension methods allow you to add functionality to existing classes. Even though they’re called methods, you can also add other members like getters, setters or even operators.
Generics refers to generalizing specific types like `String`, `bool` or `int` so you can handle them all the same way. This chapter will teach not only how to use generic types but also how to create new generic classes and collections.
Enums are more than just a set of named values. You can treat them like classes, even giving your enum properties and methods.
Try as you might, you can’t stop from making mistakes when writing code. Debugging will help you find those mistakes. However, you also need to plan for and handle exceptional situations that could crash your app.
In this chapter, you’ll learn to distinguish concurrency from parallelism. You’ll also see how Dart implements concurrency with an event loop.
Dart’s Future type is a promise to complete a task or give you a value in the future. They’re ideal for potentially time-consuming operations like making a network request or reading from a database.
A future represents a single value that will arrive in the future, but a stream represents multiple future values. This chapter will teach you how to use, transform and even create streams from scratch.
Isolates allow you to run Dart code on multiple threads. This chapter will teach you to create short-lived isolates for single tasks and long-running isolates requiring two-way communication.