axisDirectionToAxis function Null safety

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) {
  assert(axisDirection != null);
  switch (axisDirection) {
    case AxisDirection.up:
    case AxisDirection.down:
      return Axis.vertical;
    case AxisDirection.left:
    case AxisDirection.right:
      return Axis.horizontal;
  }
}