Last active
April 21, 2018 20:01
-
-
Save graphicbeacon/7865fc2b94b8896d79699f6371963064 to your computer and use it in GitHub Desktop.
Sample code for 'Learn Dart Before You Flutter' blog post on Medium (3)
This file contains 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 { | |
int _id; | |
String _reference; | |
DateTime _date; | |
String code; // public property | |
Order(this._id, this._reference, this._date); | |
Order.withDiscount(this._id, this._reference, {this.code}) { | |
_date = new DateTime.now(); | |
} | |
// Shorthand methods FTW!!! | |
String getInfo() => 'Your order information:' | |
'\n-------------------------------' | |
'\n Id: $_id' | |
'\n Reference: $_reference' | |
'\n Date: $_date' | |
'\n-------------------------------'; | |
void printInfo() => print(getInfo()); | |
} | |
void main() { | |
Order order1 = new Order.withDiscount(1, 'ref1', code: 'LOVETHEWEEKEND'); | |
order1.printInfo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment