PrimitiveGradient.byProgressiveMerge constructor Null safety

  1. PrimitiveGradient a,
  2. PrimitiveGradient b,
  3. double t

This factory constructor will return a PrimitiveGradient whose colors and stops are progressively merged (as t progresses from 0.0 -> 1.0) by lerping any entries that fall within a shared common list length range and adding any potential extra entries sourced from b as t grows while removing any potential extra entries sourced from a as t grows.


factory PrimitiveGradient.byProgressiveMerge(
    PrimitiveGradient a, PrimitiveGradient b, double t) {
  final lerpedStops = _mergeListDouble(a.stops, b.stops, t, shouldSort: true);
  // final lerpedColors = _mergeListColor(a.colors, b.colors, t);
  final lerpedColors = lerpedStops
        (double stop) => Color.lerp(
          // sample(a is Steps ? a.steppedColors : a.colors, aStops, stop),
          // sample(b is Steps ? b.steppedColors : b.colors, bStops, stop),
          sample(a.colors, a.stops, stop /*, isDecal*/),
          sample(b.colors, b.stops, stop /*, isDecal*/),
      .toList(growable: false);
  return PrimitiveGradient._(lerpedColors, lerpedStops);