Menu

1 / 5

How to play animated SVG in Flutter (flutter_svg won't)

DEV Community: dart·Ivan Chernoknizhnikov·5 days ago
#Wm9qgARO
#devtodart#devto#dev#img#svg_animate
Reading 0:00
15s threshold

Short answer: flutter_svg doesn't play SVG animations: it skips SMIL

elements like <animate> and ignores <style> , so the file shows as a still

picture. To play the animation that's already in the SVG, add

svg_animate and use

AnimatedSvgPicture where you'd use SvgPicture . It takes the same arguments:

flutter pub add svg_animate

Enter fullscreen mode

Exit fullscreen mode

AnimatedSvgPicture . asset ( 'assets/spinner.svg' , width : 48 )

Enter fullscreen mode

Exit fullscreen mode

It plays SMIL, CSS @keyframes and CSS motion paths, in pure Dart. The rest of

this post is how it works, the three bugs real files exposed, and how it

compares with Lottie, Rive and the other SVG packages.

Our designer sent me a folder of animated SVGs. A spinner, a progress bar, a

few icons. Nice stuff, all of it animated right there in the file with plain

CSS and SMIL.

I dropped them into flutter_svg and got static pictures.

I spent an evening convinced I'd broken something.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.