animateWidgetCircleShimmer method

Widget animateWidgetCircleShimmer({
  1. Alignment alignment = Alignment.center,
  2. Color color = Colors.white,
  3. int durationMs = 1500,
  4. bool repeat = true,
  5. bool animate = true,
})
  1. Circle Radial Shimmer (Loop)

Implementation

Widget animateWidgetCircleShimmer({
  Alignment alignment = Alignment.center,
  Color color = Colors.white,
  int durationMs = 1500,
  bool repeat = true,
  bool animate = true,
}) {
  if (!animate) return this;
  return _baseAnimate(repeat: repeat).custom(
    duration: durationMs.ms,
    builder: (_, v, child) {
      final double smoothV = Curves.easeInOutSine.transform(v);
      return ShaderMask(
        shaderCallback: (rect) => RadialGradient(
          center: alignment,
          radius: smoothV * 3.0,
          colors: [
            color.withColorOpacity(0.0),
            color.withColorOpacity(0.4 * (1 - smoothV.clamp(0.7, 1.0))),
            color.withColorOpacity(0.0)
          ],
          stops: const [0.0, 0.5, 1.0],
        ).createShader(rect),
        blendMode: BlendMode.srcATop,
        child: child,
      );
    },
  );
}