createShimmerGradient static method

LinearGradient createShimmerGradient({
  1. required Color baseColor,
  2. required Color highlightColor,
  3. required double animationValue,
})

Creates a shimmer gradient for animation.

Implementation

static LinearGradient createShimmerGradient({
  required Color baseColor,
  required Color highlightColor,
  required double animationValue,
}) {
  return LinearGradient(
    begin: Alignment.topLeft,
    end: Alignment.bottomRight,
    colors: [baseColor, highlightColor, baseColor],
    stops: [
      (animationValue - 0.3).clamp(0.0, 1.0),
      animationValue,
      (animationValue + 0.3).clamp(0.0, 1.0),
    ],
  );
}