-
-
Save zombiemachines/5113c053f0b75eda6d655a2817945efa to your computer and use it in GitHub Desktop.
"Learn Dart Before you Flutter" Youtube video solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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