Skip to content

Instantly share code, notes, and snippets.

@dsibinski

dsibinski/main.dart

Created Dec 4, 2019
Embed
What would you like to do?
Dart - sample app
main() {
var myCar = new Car("Cybertruck", new DateTime(2021, 01, 01));
myCar.describe();
}
class Car {
String model;
DateTime productionDate;
// Ctor: notice the syntactic sugar members' assignment
Car(this.model, this.productionDate) {
// Some other ctor init code here
}
int get productionYear =>
productionDate?.year;
void describe() {
print('Car: $model, produced in $productionYear');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment