O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

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

Summary

In this chapter, you learned that a constructor is a method that is invoked to create an object from a class. There are generative and factory constructors. The main purpose of a generative constructor is to initialize the instance of a class in a safe manner. The constructor can have required or optional parameters. The optional parameters enable the supply of arguments for only a few parameters from the list of optional parameters.

A constructor can be named. The named constructors provide intuitive and safer construction operations, because named constructors have similar code and some of them can be translated into redirecting constructors. A redirecting constructor calls another constructor that makes the code compact.

Dart supports ...

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