How to put SVG icons in flutter?

Viewed 10753

Put this code in pubspec.yaml

flutter_svg: ^0.19.3

Even I put in assets these

assets:
     - assets\icons\logo.jpg
     - assets\icons\menuicon.svg
     - assets\icons\searchIcon.svg

In code it looks like this

IconButton(
                    icon: Icon(Icons.searchicon.svg),
                    onPressed: () {},
1 Answers

The Icon parameter accept any kind of widget not only Icon So you can use any widget like below

   IconButton(icon: SvgPicture.asset(
      assetName,
      color: Colors.red,
      semanticsLabel: 'Label'
    ),onPressed: () {},
Related