Understanding classes in Dart
If you are an experienced programmer and are already familiar with Java or similar OOP languages, then you can skim through some parts of this chapter as Dart implements OOP concepts such as inheritance and encapsulation in very similar ways to those other languages. However, some areas, such as how Dart manages and defines class constructors, will probably be different from what you are used to and are incredibly important for later chapters when we explore how Flutter makes the best use of the Dart language.
In this section, we will look at what makes a Dart class, how to construct an instance of one using a constructor, and how your class can inherit from other classes. We will also explore ways to use special class constructs, such as abstract classes, interfaces, and mixins, and, finally, look at how to share class code across our code base using files and imports.
Class structure
Dart classes are declared by using the class
keyword and the...