class ClassName { factory ClassName() { // TODO: return ClassName instance } factory ClassName.namedConstructor() { // TODO: return ClassName instance } }// A factory constructor will help you to create a custom instance of a class void main() { Point point = Point.fromMap({"x": 30, "y": 90}); Point point2 = Point(10, 20); print({"Taken from Point fromMap factory",point}); print({"Taken from Point constructor", point2}); } class Point { double x, y; Point(this.x, this.y); factory Point.fromMap(Map<String, double> json) { return Point(json['x']!, json['y']!); } @override String toString() { return "toString: $x : $y"; } }