decodeGradientTransform static method

GradientTransform? decodeGradientTransform(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the given value into a GradientTransform. If the value is null then null will be returned.

When the value is not null, this will always return a concrete implementation of GradientRotation.

{
  "radians": <double>
}

Implementation

static GradientTransform? decodeGradientTransform(
  dynamic value, {
  bool validate = true,
}) {
  GradientTransform? result;

  if (value is GradientTransform) {
    result = value;
  } else if (value != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/gradient_transform',
      value: value,
      validate: validate,
    ));
    result = GradientRotation(
      JsonClass.parseDouble(value['radians'])!,
    );
  }

  return result;
}