Anar
Anar

Reputation: 121

How to put SVG icons in flutter?

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: () {},

Upvotes: 11

Views: 35363

Answers (1)

Nilesh Senta
Nilesh Senta

Reputation: 5472

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: () {},

Upvotes: 19

Related Questions