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: Fundamentals is the first of a two-book series that will teach you all the basic concepts you need to master this language. Even if you’re completely new to programming, 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: Fundamentals
You’ll set up your development environment to work with Dart, create your first Dart project and learn about its structure.
You’ll learn the basic concepts needed to start programming in Dart, such as variables and constants, comments and mathematical expressions. These will give you the foundation you need to progress in Dart.
This chapter will teach you some of the main data types in Dart and the different operations you can perform on them. You’ll also learn about type conversion and type inference. Finally, you’ll see the difference between dynamically and statically typed languages.
In this chapter, you’ll learn about strings and the way Dart represents text and characters using Unicode. You’ll also learn about concatenation and interpolation.
Control flow allows you to determine what your program does at each step. Booleans, enums, switches and if-else statements give you the ability to set the path your program will follow.
While-loops and for-loops give you the ability to repeat instructions in your code. They’re another essential aspect of control flow.
Functions allow you to organize your code in logical blocks.
Classes are one of the most important concepts in object-oriented programming. They allow you to create types, defining their properties and what they can do.
An important part of creating classes in Dart is learning about constructor methods, which include generative, named, forwarding and factory constructors.
Static members are methods and properties of a class that belong to the class itself rather than to an object constructed from a class.
Nullability allows you to handle the absence of a value while programming. While the concept of null is useful, it has traditionally plagued programmers who forget to deal with it. With sound null safety in Dart, though, it’s not possible to forget. Follow along to learn why.
In almost every application you make, you’ll deal with data collections. Lists are the primary collection type you’ll work with in Dart. They allow you to group values in an ordered sequence.
A set is a collection of elements where the order isn’t important and duplicate elements are ignored. Because of their characteristics, sets can be faster than lists for certain operations, especially when dealing with large datasets.
A maps is a data structure that holds key-value pairs. The key is the variable name and the value is the data the variable holds.
Iterables are what let you loop over collections. This chapter will teach you their characteristics and how to make custom iterables and their iterators.