Immutable Instances
Last updated
Last updated
void main() {
//immutable instances
final employee1 =
new Employee(id: 1, name: "John Doe", position: "CTO", companyname: "A");
// print(employee1.toString());
// employee1.id =2 ;
// employee1.name = "Jane Doe";
print(employee1.toString());
}
class Employee {
final int id;
final String name;
final String position;
final String companyname;
@override
String toString() {
return "id: $id , name: $name , position : $position , companyname: $companyname";
}
Employee({this.id, this.name, this.position, this.companyname});
}