12

I have to implement elevation (like a shadow) on an image widget, but I couldn't find a solution to this. Is there a way to implement elevation to an image?

An image example of what I want to remove: what I want to remove

I used the Material widget, but it renders empty space!! The original image has no spaces, how can I remove them?

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
Privacy of Animal
  • 441
  • 2
  • 10
  • 17

1 Answers1

39

You can simply use the Material or the Card widget:

Center(
  child: Material( // with Material
    child: Image.network('https://placeimg.com/640/480/any'),
    elevation: 18.0,
    shape: const CircleBorder(),
    clipBehavior: Clip.antiAlias,
  ),
),
Center(
  child: Card( // with Card
    child: Image.network('https://placeimg.com/640/480/any'),
    elevation: 18.0,
    shape: const CircleBorder(),
    clipBehavior: Clip.antiAlias,
  ),
),

If you want more control on the Radius of the Image. Then you can use CircleAvatar:

Center(
  child: Card(
    child: CircleAvatar(
      maxRadius: 54.0,
      backgroundImage:
          NetworkImage('https://placeimg.com/640/480/any'),
    ),
    elevation: 18.0,
    shape: const CircleBorder(),
    clipBehavior: Clip.antiAlias,
  ),
),
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
anmol.majhail
  • 48,256
  • 14
  • 136
  • 105
  • @PrivacyofAnimal looks like you are using `padding` widget in between. My solutions works as standalone you can run them. - with-out seeing your code its hard to debug. – anmol.majhail Feb 18 '19 at 08:36