so i want to make something similar to shimmer but it’s just fading and not sliding fading like from this package https://pub.dev/packages/fade_shimmer but since it doesn’t have child property so i want to make my own animation, i just want to create a container that has animation of blinking effect i think it only chnage the opacity but i don’t know. here is my code
late AnimationController _animationController;
late Animation<double> _animation;
@override
void initState() {
super.initState();
_animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1200),
);
_animation = Tween<double>(begin: 1, end: 0.3).animate(_animationController)
..addListener(() {
_animationController
.forward()
.then((value) => _animationController.reverse());
setState(() {});
log('animation value === ${_animation.value}');
});
}
@override
void dispose() {
super.dispose();
_animationController.dispose();
}
Container(
height: widget.height,
width: widget.width,
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.fromLTRB(widget.marginLeft ?? 0, widget.marginTop ?? 0,
widget.marginRight ?? 0, widget.marginBottom ?? 0),
decoration: BoxDecoration(
color: widget.altColor
? MyThemes.colorBrown
: MyThemes.colorLightBrown.withOpacity(_animation.value),
borderRadius: widget.radius != null
? BorderRadius.all(
Radius.circular(widget.radius ?? 0),
)
: BorderRadius.vertical(
bottom: Radius.circular(widget.radiusBottom ?? 0),
top: Radius.circular(widget.radiusTop ?? 0),
),
),
child: widget.child,
);
2
Answers
Here is what I could produce the blinking effect. You may change the duration to suit your need.
Link to the output
try this code.