Class is the blueprint for an object. It stores data as fields and behavior as methods. In app development, you'll typically model real-world entities like User, Product, Order, and Course as classes.
dart
class Course {
String title;
int lessons;
Course(this.title, this.lessons);
void describe() {
print('$title has $lessons lessons.');
}
}
void main() {
final dartCourse = Course('Dart Basic', 18);
dartCourse.describe();
}Course class has title and lessons fields. The constructor supplies values when the object is created. describe() method uses the object's data to produce a message.
You should see
Dart Basic has 18 lessons.