decodeFloatingLabelAlignment static method

FloatingLabelAlignment? decodeFloatingLabelAlignment(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the value to a FloatingLabelAlignment. Supported values are:

  • always
  • auto
  • never

Implementation

static FloatingLabelAlignment? decodeFloatingLabelAlignment(
  dynamic value, {
  bool validate = true,
}) {
  FloatingLabelAlignment? result;

  if (value is FloatingLabelAlignment) {
    result = value;
  } else {
    _checkSupported(
      'FloatingLabelAlignment',
      [
        'center',
        'start',
      ],
      value,
    );

    if (value != null) {
      assert(SchemaValidator.validate(
        schemaId: '$_baseSchemaUrl/floating_label_alignment',
        value: value,
        validate: validate,
      ));
      switch (value) {
        case 'center':
          result = FloatingLabelAlignment.center;
          break;

        case 'start':
          result = FloatingLabelAlignment.start;
          break;
      }
    }
  }

  return result;
}