How to put SVG icons in flutter?

5,678

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: () {},
Share:
5,678
Anar
Author by

Anar

Updated on December 29, 2022

Comments

  • Anar
    Anar over 1 year

    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: () {},
    
  • Hamdam Muqimov
    Hamdam Muqimov over 2 years
    The problem is we have to manually control theming on each icon. It does not inherit IconTheme class.