setter and getter in dart code example
Example 1: dart setters
// getter: return_type get field_name { }
String get emp_name {
return empName;
}
// setter: set field_name { }
void set emp_name(String name) {
this.empName = name;
}
Example 2: dart getter
int get age => 21;
void set age(int currentYear) =>
vehicleAge = currentYear - manufactureYear;