flutter_animate icon indicating copy to clipboard operation
flutter_animate copied to clipboard

ShimmerEffect alters widget dimensions

Open ifuterman opened this issue 2 years ago • 1 comments
trafficstars

Animation widget has its dimensions 1 px at the bottom and 1 px on the right side In this snipet container will be overflowed at the bottom by 1 px

Container(
  height: 86,
  color: Colors.red,
  child: Animate(
    effects: [
      ShimmerEffect(
      duration: 1000.ms,
      color: AppColors.shimmerAnimationCollor
      )
    ],
    controller: _animationController,
    onPlay: (controller) => controller.repeat(),
    child: Container(
      height: 86,
    )
 )
)

ifuterman avatar Aug 28 '23 13:08 ifuterman

This is because ShaderMask doesn't do a particularly good job with edges, so by default ShimmerEffect adds 0.5px of padding around the widget to avoid visual artifacts.

You can disable this by setting padding: EdgeOffsets.zero.

I think I can work around this by creating a PaddedShaderMask, having it apply the padding, but return the original dimensions for layout. I'll put it on my list, but feel free to look into it in the interim.

gskinner avatar Aug 28 '23 18:08 gskinner