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
),
),
),
),
2
Answers
Update the
pubspec.yaml
file.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.
You possibly have not uncommented these lines in
pubspec.yaml