Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter SVG as ImageIcon

Tags:

flutter

dart

My designer has switched from PNG to SVG files, 'cause our icons are to pixelated.

How I can use a SVG as an ImageIcon?.

Previous I have used this for PNG files:

ImageIcon(AssetImage('assets/images/ic_home.png')

I'm using flutter_svg (SvgPicture.asset(item.icon, height: 24, width: 24))

Thank you in advance for your help!

like image 321
ruclip Avatar asked Oct 28 '25 14:10

ruclip


1 Answers

You actually can't do it as mentioned here by Flutter SVG creator that PictureProvider and ImageProvider are incompatible and ImageIcon needs an ImageProvider.

However, you don't actually need to do it, and you probably won't as well. You can refactor your code to use:

SvgPicture.asset(item.icon, height: 24, width: 24)

And nothing else. That should be enough, no need for more complexity.

like image 197
Miguel Ruivo Avatar answered Oct 30 '25 05:10

Miguel Ruivo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!