shimmer method

Widget shimmer({
  1. bool shimmer = true,
  2. double? width,
  3. double? height,
  4. double? shimmerAngle,
  5. Duration? duration,
  6. double? speedFactor,
  7. Color? baseColor,
  8. Color? highlightColor,
  9. List<Color>? gradientColors,
  10. ShimmerDirection? direction,
  11. ShimmerEffect? effect,
  12. Duration? disableAfter,
  13. double borderRadius = 8.0,
})

Applies a shimmer effect to the text.

If shimmer is false, it returns the original text.

Implementation

Widget shimmer({
  bool shimmer = true,
  double? width, // Custom width
  double? height, // Custom height
  double? shimmerAngle,
  Duration? duration,
  double? speedFactor,
  Color? baseColor,
  Color? highlightColor,
  List<Color>? gradientColors,
  ShimmerDirection? direction,
  ShimmerEffect? effect,
  Duration? disableAfter,
  double borderRadius = 8.0, // NEW: Rounded corner support
}) {
  if (!shimmer) return this; // Return original text if shimmer is disabled

  final theme = ShimmerTheme();

  return Shimmer(
    shimmerAngle: shimmerAngle ?? theme.shimmerAngle,
    duration: duration ?? theme.duration,
    speedFactor: speedFactor ?? theme.speedFactor,
    baseColor: baseColor ?? theme.baseColor,
    highlightColor: highlightColor ?? theme.highlightColor,
    gradientColors: gradientColors,
    direction: direction ?? theme.direction,
    effect: effect ?? theme.effect,
    disableAfter: disableAfter ?? theme.disableAfter,
    child: SizedBox(
      width: width,
      height: height,
      child: Container(
        decoration: BoxDecoration(
          color: theme.baseColor, // Hide text with theme's base color
          borderRadius: BorderRadius.circular(borderRadius), // Apply rounded corners
        ),
        child: Opacity(
          opacity: 0.0, // Hide the text
          child: Text(
            data ?? "",
            style: style,
          ),
        ),
      ),
    ),
  );
}