Implicit / Default Getters & Setters
Getters and setters are special methods that provide read and write access to an object’s properties
Last updated
Was this helpful?
Getters and setters are special methods that provide read and write access to an object’s properties
Last updated
Was this helpful?
Was this helpful?
void main() {
// Default/ Implicit Getters & Setters
var employee1 = Employee(); // Creating employee1 object
var employee2 = Employee(); // Creating employee2 object
// Setting the instance variable of employee1 object
// Implict Setters
employee1.id =1;
employee1.name ="John Doe";
employee1.position ="CTO";
employee2.id =2;
employee2.name ="Jane Doe";
employee2.position ="CEO";
// Implicit Getters
print(employee1.id);
print(employee1.name);
print(employee1.position);
print(employee2.id);
print(employee2.name);
print(employee2.position);
}
class Employee{
int id;
String name;
String position;
}