axisDirectionToAxis function

Axis axisDirectionToAxis(
  1. AxisDirection axisDirection
)

Returns the Axis that contains the given AxisDirection.

Specifically, returns Axis.vertical for AxisDirection.up and AxisDirection.down and returns Axis.horizontal for AxisDirection.left and AxisDirection.right.

Implementation

Axis axisDirectionToAxis(AxisDirection axisDirection) {
  return switch (axisDirection) {
    AxisDirection.up   || AxisDirection.down  => Axis.vertical,
    AxisDirection.left || AxisDirection.right => Axis.horizontal,
  };
}