O'Reilly logo

Mastering Dart by Sergey Akopkokhyants

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Object Creation

In this chapter, we will talk about the creation of objects. We will see how and when to create them using best practices from the programming world, and then find a place for them to be accommodated in Dart. The different techniques covered here will help us to make correct choices that will be useful in different business cases. In this chapter, we will cover the following topics:

  • A generative constructor
  • A constructor with optional parameters
  • A named constructor
  • A redirecting constructor
  • A private constructor
  • A factory constructor
  • A constant constructor
  • Initialization of variables
  • Syntactic sugar

Creating an object

A class is a blueprint for objects. The process of creating objects from a class is called instantiation. An object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required