0PricingLogin
Dart Academy · Lesson

Default and Parameterized Constructors

Initialize fields when creating objects.

What a Constructor Does

A constructor is the special method that builds a new object and sets up its starting state when you write the class name. 🏗️

The Default Constructor

If you write no constructor at all, Dart gives you a free default constructor that takes no arguments and creates a bare object.

class Dog {}
var d = Dog(); // uses the default constructor

All lessons in this course

  1. Default and Parameterized Constructors
  2. Named Constructors for Clear Intent
  3. Initializer Lists and Redirecting
  4. Factory and const Constructors
← Back to Dart Academy