Classes
A class has fields, a constructor and methods. No new keyword is needed.
Example
class Dog {
final String name;
Dog(this.name);
String speak() => "$name says woof";
}
void main() {
var d = Dog("Rex");
print(d.speak());
}Exercise
Initialising formal.
Dog(.name);
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.