I need to represent a photo with a Dart 2 class. The photo can be rectangular or circular. So, with a polymorphism I could write:
import 'dart:math';
class Photo {
double width;
double height;
double radius;
double area;
Photo(double width, double height) {
this.width = width;
this.height = height;
this.area = width * height;
}
Photo(double radius) {
this.radius = radius;
this.area = pi * pow(radius, 2);
}
}
So I could allow to create a Photo with radius or a Photo with width and height; no other option.
How can I do this with Dart 2?
Thanks!