flutter constructor example
Example 1: constructor in dart
void main(){
SelfDrivingCar myLamb = SelfDrivingCar('Floride');
myLamb.drive();
}
class Car {
int numberofwheels = 4;
void drive() {
print('this is a car');
}
}
class SelfDrivingCar extends Car {
String destination='k';
SelfDrivingCar(String userDestination){
destination = userDestination;
}
@override
void drive() {
super.drive();
print('sterring wheel to $destination');
}
}
Example 2: constructoers in flutter
Customer(this.name, this.age, this.location);
Customer.withoutLocation(this.name, this.age);
Customer.empty() {
name = "";gd
location = "";
}
cfgdfgdfgdfggdfgdfdfgdfgdggdfgdfgdf