I have this abstract class
abstract class DrawObject {
Path _path = Path();
Color _color = Colors.black;
double _strokeWidth = 2;
PaintingStyle _paintingStyle = PaintingStyle.stroke;
DrawObject({Color? color, double? strokeWidth}) {
_color = color ?? Colors.black;
_strokeWidth = strokeWidth ?? 2;
}
}
and this extend
class Circle extends Shape {
Circle({
Color? color,
required super.offset,
required super.size,
required double strokeWidth,
}) : super() {
_color = color ?? Colors.black; // this line
_path = setPath();
_strokeWidth = strokeWidth;
}
}
Now I have to check null for every shape I created.
Can I use abstract class constructor for define the default value only once?
It’s dart btw