getDefaultCrossAxisDirection static method

AxisDirection getDefaultCrossAxisDirection(
  1. BuildContext context,
  2. AxisDirection axisDirection
)

Given a BuildContext and an AxisDirection, determine the correct cross axis direction.

This depends on the Directionality if the axisDirection is vertical; otherwise, the default cross axis direction is downwards.

Implementation

static AxisDirection getDefaultCrossAxisDirection(BuildContext context, AxisDirection axisDirection) {
  switch (axisDirection) {
    case AxisDirection.up:
      assert(debugCheckHasDirectionality(
        context,
        why: "to determine the cross-axis direction when the viewport has an 'up' axisDirection",
        alternative: "Alternatively, consider specifying the 'crossAxisDirection' argument on the Viewport.",
      ));
      return textDirectionToAxisDirection(Directionality.of(context));
    case AxisDirection.right:
      return AxisDirection.down;
    case AxisDirection.down:
      assert(debugCheckHasDirectionality(
        context,
        why: "to determine the cross-axis direction when the viewport has a 'down' axisDirection",
        alternative: "Alternatively, consider specifying the 'crossAxisDirection' argument on the Viewport.",
      ));
      return textDirectionToAxisDirection(Directionality.of(context));
    case AxisDirection.left:
      return AxisDirection.down;
  }
}