GradientCopyWith typedef Null safety

GradientCopyWith = Gradient Function(Gradient gradient, {AlignmentGeometry? begin, AlignmentGeometry? center, List<Color>? colors, double? distance, AlignmentGeometry? end, double? endAngle, AlignmentGeometry? focal, double? focalRadius, double? radius, double? shadeFactor, ColorArithmetic? shadeFunction, double? softness, double? startAngle, List<double>? stops, TileMode? tileMode, GradientTransform? transform})

Provision of a function type defintion for the purpose of allowing the override of this package's default copyWith() method.

The default GradientCopyWith for this package is spectrumCopyWith, a wrapper for GradientUtils extension method Gradient.copyWith.

Imagine for a a bespoke Gradient type from a source other than those recognized by this package, an overridden GradientCopyWith
(say like the one requested by GradientTween._copyWith, itself forwarding that function to IntermediateGradient._copyWith)
could be used to ensure that the inner workings of the Gradient interpolation return back the correct, custom Gradient.


Such as:

Gradient customCopyWith(Gradient original, { List<Color>? colors, List<double>? stops, . . . /* optionals */ })
    => CustomGradient(
         colors: colors ?? original.colors,
         stops: stops ?? original.stops,
         . . . );

final tween = GradientTween(
  begin: customGradient,
  end: differentCustomGradient,
  overrideCopyWith: customCopyWith);

Implementation

typedef GradientCopyWith = Gradient Function(
  Gradient gradient, {
  // Universal
  List<Color>? colors,
  List<double>? stops,
  GradientTransform? transform,
  TileMode? tileMode,
  // Linear
  AlignmentGeometry? begin,
  AlignmentGeometry? end,
  // Radial or Sweep
  AlignmentGeometry? center,
  // Radial
  double? radius,
  AlignmentGeometry? focal,
  double? focalRadius,
  // Sweep
  double? startAngle,
  double? endAngle,
  // Steps
  double? softness,
  // Shaded Steps
  ColorArithmetic? shadeFunction,
  double? shadeFactor,
  double? distance,
});