Sitemap
MD. SAKIF RAHAMAN MISHAD

MD. SAKIF RAHAMAN MISHAD

CS student & self-taught app developer. Learning by building. Breaking things. Fixing them better

Constructors in Dart

What is a Constructor?

A constructor is a special method in a class that is automatically called when an object is created.

Get MD. SAKIF RAHAMAN MISHAD’s stories in your inbox

Join Medium for free to get updates from this writer.

It is used to initialize fields and set default or custom values when a new instance of the class is created.

A constructor:
• Has the same name as the class
• Does not have a return type (not even void)

Syntax

class ClassName {
ClassName() {
// Initialization code
}
}

--

--

MD. SAKIF RAHAMAN MISHAD
MD. SAKIF RAHAMAN MISHAD

Written by MD. SAKIF RAHAMAN MISHAD

0 followers

CS student & self-taught app developer. Learning by building. Breaking things. Fixing them better