Skip to content

Instantly share code, notes, and snippets.

@inialdan
Created March 3, 2021 13:04
Show Gist options
  • Save inialdan/c1d8489794b8b13d9319cb6ea16faf03 to your computer and use it in GitHub Desktop.
Save inialdan/c1d8489794b8b13d9319cb6ea16faf03 to your computer and use it in GitHub Desktop.
Aldan 065118112 - Use optional parameters
import 'dart:math';
class Rectangle {
int width;
int height;
Point origin;
Rectangle({this.origin = const Point(0, 0), this.width = 0, this.height = 0});
@override
String toString() =>
'Origin: (${origin.x}, ${origin.y}), width: $width, height: $height';
}
main() {
print(Rectangle(origin: const Point(10, 20), width: 100, height: 200));
print(Rectangle(origin: const Point(10, 10)));
print(Rectangle(width: 200));
print(Rectangle());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment