Home > OS >  How to resolve ImageIcon issue in flutter
How to resolve ImageIcon issue in flutter

Time:11-28

Trying to set image for icon in flutter but not working. So, How to set path for ImageIcon in ListTile.

This line is not working:

leading: ImageIcon(AssetImage('images/abt.png'), size: 25),
        GestureDetector(
            onTap: ()
            {
              Navigator.push(context, MaterialPageRoute(builder: (c)=> AboutScreen()));
            },
            child: const ListTile(
              tileColor: Colors.blue,
              leading: ImageIcon(AssetImage('images/abt.png'), size: 25),
              title: Text(
                "About",
                style: TextStyle(
                    color: Colors.black
                ),
              ),
            ),
          ),

CodePudding user response:

You possibly have not uncommented these lines in pubspec.yaml

# assets:
#  - images/a_dot_burr.jpeg
#  - images/a_dot_ham.jpeg

CodePudding user response:

Update the pubspec.yaml file.

assets:  
    - images/
    - images/abt.png  

Flutter uses the pubspec.yaml file, located at the root of your project, to identify assets required by an app. Read here how to specify assets and images in Flutter.

  • Related