decodeRangeSliderThumbShape static method

RangeSliderThumbShape? decodeRangeSliderThumbShape(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the given value to a RangeSliderThumbShape. This expects a "type" attribute to be one of:

  • round

The structure of the other attributes depends on the "type".

Type: round

{
  "disabledThumbRadius": "<double>",
  "enabledThumbRadius": "<double>",
  "elevation": "<double>",
  "pressedElevation": "<double>",
  "type": "round"
}

Implementation

static RangeSliderThumbShape? decodeRangeSliderThumbShape(
  dynamic value, {
  bool validate = true,
}) {
  RangeSliderThumbShape? result;
  if (value is RangeSliderThumbShape) {
    result = value;
  } else {
    assert(value == null || value['type'] is String);
    _checkSupported(
      'RangeSliderThumbShape.type',
      [
        'round',
      ],
      value == null ? null : value['type'],
    );

    if (value != null) {
      assert(SchemaValidator.validate(
        schemaId: '$_baseSchemaUrl/range_slider_thumb_shape',
        value: value,
        validate: validate,
      ));

      final String? type = value['type'];
      switch (type) {
        case 'round':
          result = RoundRangeSliderThumbShape(
            disabledThumbRadius: JsonClass.maybeParseDouble(
              value['disabledThumbRadius'],
            ),
            elevation: JsonClass.maybeParseDouble(value['elevation']) ?? 1.0,
            enabledThumbRadius: JsonClass.maybeParseDouble(
                  value['enabledThumbRadius'],
                ) ??
                10.0,
            pressedElevation: JsonClass.maybeParseDouble(
                  value['pressedElevation'],
                ) ??
                6.0,
          );
          break;
      }
    }
  }

  return result;
}