Person is a class with properties name and age.Person(this.name, this.age) initializes the properties.greet is a method of the Person class.person is an object of the Person class.person.name, person.greet()).class Person { String name; // Property: name int age; // Property: age
// Constructor to initialize properties Person([this.name](<http://this.name/>), this.age);
// Method to display a greeting void greet() { print("Hello, my name is $name and I am $age years old."); } }
void main() { var person = Person("Alice", 30); // Create an object with name "Alice" and age 30 print([person.name](<http://person.name/>)); // Access property: Output: Alice print(person.age); // Access property: Output: 30 person.greet(); // Call method: Output: Hello, my name is Alice and I am 30 years old. }