Skip to content

Instantly share code, notes, and snippets.

@graphicbeacon
Created March 19, 2020 20:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save graphicbeacon/e65ca023d7117e05e13b90076e450f18 to your computer and use it in GitHub Desktop.
Save graphicbeacon/e65ca023d7117e05e13b90076e450f18 to your computer and use it in GitHub Desktop.
"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