operator / method

Point operator /(
  1. num scalar
)

Overrides the division (/) operator.

Divides the x, y, and z coordinates of this point by scalar. If z is null, the resulting point will be 2-dimensional. If scalar is zero, throws an ArgumentError.

Example:

var point = Point(4, 6);
print(point / 2); // Output: Point(2.0, 3.0)

Returns a new Point.

Implementation

Point operator /(num scalar) {
  if (scalar == 0) throw ArgumentError('Cannot divide by zero.');
  return Point(x / scalar, y / scalar, z != null ? z! / scalar : null);
}