OLD | NEW |
(Empty) | |
| 1 import 'dart:html'; // Dart supports libraries... |
| 2 |
| 3 class Rectangle implements Shape { // ...and classes. |
| 4 final num height, width; |
| 5 Rectangle(this.height, this.width); // Compact constructor syntax. |
| 6 num perimeter() => 2*height + 2*width; // Function shorthand syntax. |
| 7 } |
| 8 |
| 9 // You can define functions either inside or outside of classes. |
| 10 startOrEndTest() { |
| 11 // ... |
| 12 } |
| 13 |
| 14 // Every app has a main() function, where execution starts. |
| 15 main() { |
| 16 // The cascade operator (..) saves you from repetitive typing. |
| 17 query("#button") |
| 18 ..text = "Run test" |
| 19 ..onClick.listen(startOrEndTest); |
| 20 } |
| 21 |
| 22 class Shape {} |
OLD | NEW |