Preview:
class Employee{
  String _empName;
  double _empSalary;
  
  Employee(this._empName, this._empSalary);
  
  String get empName => _empName;
  
  set empName(String empName) {
    if(empName.length >= 3 && empName.length <= 25){
      _empName = empName;
    } else {
      print("EmpName should be of appropriate length");
    }
  } 
  
  
  double get empSalary => _empSalary;
}

void main(){
  Employee manish = Employee("Manish Basnet" , 20000);
  manish.empName = "MB";
  print(manish.empName);
  print(manish.empSalary);
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter