class Employee{ String empName; DateTime joiningDate; Employee(this.empName, this.joiningDate); int get daysOfWork{ return DateTime.now().difference(joiningDate).inDays; } } void main(){ Employee m = Employee("Manish", DateTime(2023,07,12)); print(m.daysOfWork); }
Preview:
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