12. Optional types
Every variable
is object
Top level main()
function
Checked and
Production
modes
Syntactic sugar
Named
constructors
… and more
about.me/janamou
13. Optional types
var x = 10;
var y = 20;
or
num x = 10;
num y = 20;
about.me/janamou
15. Syntactic sugar
class Person {
String firstName;
String lastName;
int age;
Person(this.firstName, this.lastName);
}
void main() {
Person person = new Person("Jana", "Moudrá");
}
about.me/janamou
16. Named constructor
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);
}
about.me/janamou
17. Getter/Setter
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;
}
about.me/janamou