animateLiquidFill method

Widget animateLiquidFill({
  1. Color color = Colors.greenAccent,
  2. bool animate = true,
})
  1. Liquid Fill Shimmer

Implementation

Widget animateLiquidFill(
    {Color color = Colors.greenAccent, bool animate = true}) {
  if (!animate) return this;
  return this
      .animate(onPlay: (controller) => controller.repeat(reverse: true))
      .custom(
        duration: 3000.ms,
        builder: (context, value, child) => ShaderMask(
          shaderCallback: (rect) => LinearGradient(
            begin: Alignment.bottomCenter,
            end: Alignment.topCenter,
            colors: [color, Colors.transparent],
            stops: [value, value + 0.1],
          ).createShader(rect),
          blendMode: BlendMode.srcATop,
          child: child,
        ),
      );
}