Offset.fromDirection constructor Null safety

Offset.fromDirection(
  1. double direction,
  2. [double distance = 1.0]
)

Creates an offset from its direction and distance.

The direction is in radians clockwise from the positive x-axis.

The distance can be omitted, to create a unit vector (distance = 1.0).

Implementation

factory Offset.fromDirection(double direction, [ double distance = 1.0 ]) {
  return Offset(distance * math.cos(direction), distance * math.sin(direction));
}