Classes and Objects in Dart
Dart is an object-oriented language, which means that it supports classes and objects. Classes are used to define the properties and behaviors of an object, and objects are instances of a class.
class Person {
String name;
int age;
Person(this.name, this.age);
void sayHello() {
print('Hello, my name is $name');
}
}
void main() {
var person = Person('John Doe', 25);
person.sayHello();
}
No comments:
Post a Comment