lerp static method

Implementation

static DynamicBorderSide lerp(
    DynamicBorderSide a, DynamicBorderSide b, double t) {
  if (t == 0.0) return a;
  if (t == 1.0) return b;
  final double width = lerpDouble(a.width, b.width, t) ?? 0.0;
  if (width < 0.0) return DynamicBorderSide.none;
  if (a.style == b.style) {
    return DynamicBorderSide(
      color: Color.lerp(a.color, b.color, t)!,
      gradient: Gradient.lerp(a.gradient, b.gradient, t),
      width: width,
      style: a.style,
      // == b.style
      begin: Dimension.lerp(a.begin, b.begin, t),
      end: a.end == null && b.end == null
          ? null
          : Dimension.lerp(
              a.end ?? 100.toPercentLength, b.end ?? 100.toPercentLength, t),
      shift: Dimension.lerp(a.shift, b.shift, t),
      strokeCap: t < 0.5 ? a.strokeCap : b.strokeCap,
      strokeJoin: t < 0.5 ? a.strokeJoin : b.strokeJoin,
    );
  }
  Color colorA, colorB;
  switch (a.style) {
    case BorderStyle.solid:
      colorA = a.color;
      break;
    case BorderStyle.none:
      colorA = a.color.withAlpha(0x00);
      break;
  }
  switch (b.style) {
    case BorderStyle.solid:
      colorB = b.color;
      break;
    case BorderStyle.none:
      colorB = b.color.withAlpha(0x00);
      break;
  }
  return DynamicBorderSide(
    color: Color.lerp(colorA, colorB, t)!,
    gradient: Gradient.lerp(a.gradient, b.gradient, t),
    width: width,
    style: BorderStyle.solid,
    begin: Dimension.lerp(a.begin, b.begin, t),
    end: a.end == null && b.end == null
        ? null
        : Dimension.lerp(
            a.end ?? 100.toPercentLength, b.end ?? 100.toPercentLength, t),
    shift: Dimension.lerp(a.shift, b.shift, t),
    strokeCap: t < 0.5 ? a.strokeCap : b.strokeCap,
    strokeJoin: t < 0.5 ? a.strokeJoin : b.strokeJoin,
  );
}