as method

T as(
  1. Gradient gradient
)

Converts a Gradient object to the specific type T.

Throws an UnimplementedError if the given gradient type is not supported.

Implementation

T as(Gradient gradient) {
  if (gradient is RadialGradient) {
    return radial.as(gradient);
  } else if (gradient is LinearGradient) {
    return linear.as(gradient);
  } else if (gradient is SweepGradient) {
    return sweep.as(gradient);
  }
  throw UnimplementedError(
    'Cannot create GradientAttribute from gradient of type ${gradient.runtimeType}',
  );
}