dart on keyword code example
Example 1: dart function
when you want to make a function that
doesn't use the format return or a function that doesn't return a value
the function base will look like this:
void functionName() {
}
if its returning some thing it will look like this:
functionName() {
}
Example 2: with keyword in dart
mixin Human {
String name;
int age;
void about();
}
class Doctor with Human {
String specialization;
Doctor(String doctorName, int doctorAge, String specialization) {
name = doctorName;
age = doctorAge;
this.specialization = specialization;
}
void about() {
print('$name is $age years old. He is $specialization specialist.');
}
}
void main() {
Doctor doctor = Doctor("Harish Chandra", 54, 'child');
print(doctor.name);
print(doctor.age);
doctor.about();
}