Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"Learn Dart Before you Flutter" Youtube video solution
class Order {
var _id;
var _reference;
var date;
var code;
List<String> bookings;
Order(this._id, this._reference, {this.date});
Order.withDiscount(this._id, this._reference, [this.code]) {
date = DateTime.now();
}
getInfo() {
print('''Your order information:
------------------------
Id: $_id
Reference: $_reference
Date: $date
${code != null ? 'Code: $code' : ''}
------------------------''');
}
}
void main() {
Order order1 = Order(1, 'ref1', date: DateTime.now());
Order order2 = Order.withDiscount(2, 'ref2')
..code = 'DARTROCKS!'
..bookings = ['booking1', 'booking2', 'booking3']
..getInfo();
order1.getInfo();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment