setInterpolation method

KeyframeTrack setInterpolation(
  1. int interpolation
)

Implementation

KeyframeTrack setInterpolation(int interpolation) {
  Function(dynamic result)? factoryMethod;

  switch (interpolation) {
    case InterpolateDiscrete:
      factoryMethod = interpolantFactoryMethodDiscrete;
      break;
    case InterpolateLinear:
      factoryMethod = interpolantFactoryMethodLinear;
      break;
    case InterpolateSmooth:
      factoryMethod = interpolantFactoryMethodSmooth;
      break;
  }

  if (factoryMethod == null) {
    final message = 'unsupported interpolation for $valueTypeName keyframe track named $name';

    if (createInterpolant == null) {
      // fall back to default, unless the default itself is messed up
      if (interpolation != defaultInterpolation) {
        setInterpolation(defaultInterpolation);
      } else {
        throw (message); // fatal, in this case

      }
    }

    console.info('KeyframeTrack: $message');
    return this;
  }

  createInterpolant = factoryMethod;

  return this;
}