I am trying to implement the animation in the video link below:
The Icon that is being animated is a single SVG
file with three arrows. The arrows are not separate images or icon assets.
So, What I tried to accomplish that is, I used flutter_svg
and flutter_animate
packages.
First of all, I added the SVG file and gave it the greenish color, and then added shimmer effect (did not get the expected outcome). Here is the code snippet.
SvgPicture.asset(
'assets/icons/down_arrows.svg',
height: 32.h,
width: 32.h,
colorFilter: const ColorFilter.mode(
AppColors.bottomNavIconGreen,
BlendMode.srcIn,
),
)
.animate(
onPlay: (controller) => controller.repeat(period: 3000.ms))
.shimmer(
color: AppColors.mainGreen,
angle: 1.5,
),
Kindly help me achieve the animation like the video with this approach or any other way. Thank you all in advance.
2
Answers
Kindly review this video. I believe it will be beneficial.
This kind of animation can be done in flutter but this needs few different components to work. I can think of an approach to draw canvas with arrows & animate the canvas.
1. You need Animation tween to do this with loop.
2. Then we need own canvas to draw arrows. Then you need to pass
}
3. Now we need to add the custom paint to draw this canvas
This will give you something like this
4. Now we add the value param in our custom painter
and use this value to change arrow colors
and setup out shouldRepaint to reload when value changed
5. One last this is passing our animation value to our painter
6. Lastly don’t forgot to dispose the controller on stateful widget
Now running the app will give you animated arrows just like your video. Example images:
Runnig dartpad example