Dart has a special constructor that can be accessed the way we access methods. Such constructors can be much helpful to see what the code does. Rather than having constructors with same name and different parameters, dart provides a constructor with different parameters that can be named.
class Polygon{
final String shape;
int radius;
//default constructor
Polygon({required this.shape, required this.radius});
//named constructor
Polygon.triangle({required int rad}) : shape = 'triangle', radius = rad;
Polygon.square({required int rad}) : shape = 'square', radius = rad;
}