1

I am trying to display the image in the Card widget in leading CircleAvatar below is my code

child: Card(
          child: ListTile(
            onTap: () {},
            title: Text(locations[index].location.toString()),
            leading: CircleAvatar(
              radius: 18.0,
              backgroundImage:
                  AssetImage('assets/${locations[index].flag}'),)

Instead of the real image, I want to show, Blue color is displayed in the circle as shown in below attachment Image

Ahmad Raza
  • 758
  • 7
  • 26

3 Answers3

1

Add this to CircleAvatar backgroundColor: Colors.transparent,

1
  • First, make you have added image on pubspec.yaml.
  • while loading data from asset, do restart the app, not hot reload or restart.
  • if it fails, do flutter clean and run again.
  • else, make sure about image path.
  • also check this doc for supported image in flutter
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
-1

Remember this principle in your pubspec.yaml file

asset #(1 tab or 2 whitespaces) - assets/ #(2 tabs or 4 whitespaces)

This worked for me!

Dharman
  • 30,962
  • 25
  • 85
  • 135