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 programs and backend servers to your own apps for Android, iOS, the web, Mac, Windows, and Linux. Dart was the language of choice for Flutter, and their popularity has skyrocketed in recent years.
Darts Apprentice: The Basics is the first of a two-book series that will teach you all the basic concepts you need to master the language. Even if you’re completely new to programming, follow the clearly explained concepts and you’ll be building Dart applications in no time.
Before you start
This section covers 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.
Darts Apprentice: The Basics
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 you need to start programming in Dart, such as variables and constants, comments, and mathematical expressions. This will give you the foundation you need to progress in Dart.
This chapter will teach you about some of the basic data types in Dart and the various operations you can perform on them. You will also learn about type conversion and type inference. Finally, you will see the difference between dynamically and statically typed languages.
In this chapter, you’ll learn about strings and how Dart represents text and characters using Unicode. You will also learn about concatenation and interpolation.
Control flow allows you to define what your program does at each step. Boolean values, enumerations, switches, and if-else statements give you the ability to specify the path your program will follow.
While and for loops give you the ability to repeat instructions in your code. They are another essential aspect of control flow.
Functions allow you to organize code into logical blocks.
Classes are one of the most important concepts in object-oriented programming. They allow you to create types by defining their properties and what they can do.
An important part of creating classes in Dart is learning constructor methods, which include generative, nominal, redirect, and factory constructors.
Static members are methods and properties of a class that belong to the class itself, not to an object created from the class.
Nullability allows you to handle the absence of a value during programming. Although the concept of zero is useful, it has traditionally plagued programmers who forget to deal with it. However, with zero sound security in the Dart, it’s impossible to forget. To find out why.
In almost every program you run, you’ll be dealing with data collection. Lists are the primary type of collection you will work with in Dart. They allow you to group values in an ordered sequence.
A set is a collection of elements where order is not important and duplicates are ignored. Because of their characteristics, sets can perform faster than lists for certain operations, especially when working with large data sets.
Maps are data structures that contain key-value pairs. The key is the name of the variable and the value is the data that the variable contains.
Iterables are what allow you to iterate over collections. This chapter will teach you about their characteristics and how to create custom iterators and their iterators.