xxxxxxxxxx
Customer(String name, int age, String location) {
this.name = name;
this.age = age;
this.location = location;
}
Customer(this.name, this.age) {
this.name = name;
this.age = age;
}
xxxxxxxxxx
class Customer {
String name;
int age;
String location;
// constructor
Customer(String name, int age, String location) {
this.name = name;
this.age = age;
this.location = location;
}
}
xxxxxxxxxx
class Student{
Student(int enNum){
print(enNum);
}
}
main(){
var myStudent = new Student(15);
}
xxxxxxxxxx
// blueprint for the person object
class Person{
// a variable inside a class is known as a property
String name;
int age;
// constructor (kind of method 'function within a class')
// this. - refers to the class level 'name' and 'age'
// {} - allows us to use named parameters / arguments
// without {} - positional parameters / arguments
Person({this.name = "",this.age = 0});
}
void main() {
// create instance of the Person object
var person1 = Person(name: 'Max',age: 30);
var person2 = Person(name: 'Manu',age: 21);
print(person1.name);
print(person2.name);
print(person1.age);
print(person2.age);
}
xxxxxxxxxx
Customer(this.name, this.age, this.location);
Customer.withoutLocation(this.name, this.age);
Customer.empty() {
name = "";gd
location = "";
}
cfgdfgdfgdfggdfgdfdfgdfgdggdfgdfgdf