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
}
}




