decodePanAxis static method

PanAxis? decodePanAxis(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the value to a PanAxis. Supported values are:

  • aligned
  • free
  • horizontal
  • vertical

Implementation

static PanAxis? decodePanAxis(
  dynamic value, {
  bool validate = true,
}) {
  PanAxis? result;

  if (value is PanAxis) {
    result = value;
  } else if (value != null) {
    _checkSupported(
      'PanAxis',
      [
        'aligned',
        'free',
        'horizontal',
        'vertical',
      ],
      value,
    );
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/pan_axis',
      value: value,
      validate: validate,
    ));

    switch (value) {
      case 'aligned':
        result = PanAxis.aligned;
        break;

      case 'free':
        result = PanAxis.free;
        break;

      case 'horizontal':
        result = PanAxis.horizontal;
        break;

      case 'vertical':
        result = PanAxis.vertical;
        break;
    }
  }

  return result;
}