decodeAxis static method

Axis? decodeAxis(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the given value to an Axis. Supported values are:

  • horizontal
  • vertical

Implementation

static Axis? decodeAxis(
  dynamic value, {
  bool validate = true,
}) {
  Axis? result;
  if (value is Axis) {
    result = value;
  } else {
    _checkSupported(
      'Axis',
      [
        'horizontal',
        'vertical',
      ],
      value,
    );

    if (value != null) {
      assert(SchemaValidator.validate(
        schemaId: '$_baseSchemaUrl/axis',
        value: value,
        validate: validate,
      ));
      switch (value) {
        case 'horizontal':
          result = Axis.horizontal;
          break;
        case 'vertical':
          result = Axis.vertical;
          break;
      }
    }
  }

  return result;
}