Short presentation about Dart presented before Code Lab.
Code Lab is available on the Github:
* https://github.com/Janamou/dart-codelab/
* https://github.com/Janamou/dart-codelab/wiki
13. class Person {
String firstName;
String lastName;
int age;
Person(this.firstName, this.lastName);
}
void main() {
Person person = new Person("Jana", "Moudrá");
}
Syntactic sugar
14. class Person {
String firstName;
String lastName;
int age;
Person(this.firstName, this.lastName);
Person.withAge(this.lastName, this.age);
}
void main() {
Person person = new Person.withAge("Moudrá", 25);
}
Named constructors
15. class Person {
String _firstName;
String _lastName;
int _age;
Person(this._firstName, this._lastName);
Person.withAge(this._lastName, this._age);
int get age => _age;
set age(int age) => _age = age;
}
Getter and Setter