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