default cuntion on construct dart code example
Example 1: dart call constructor in constructor
class Chipmunk {
String name;
int fame;
Chipmunk.named(this.name, [this.fame]);
Chipmunk.famous1() : this.named('Chip', 1000);
factory Chipmunk.famous2() {
var result = new Chipmunk.named('Chip');
result.fame = 1000;
return result;
}
}
Example 2: flutter constructor default value
class Customer {
String name;
int age;
String location;
Customer(this.name, [this.age, this.location = "US"]);
@override
String toString() {
return "Customer [name=${this.name},age=${this.age},location=${this.location}]";
}
}