How to do Rounded Corners Image in Flutter

I am using Flutter to make a list of information about movies. Now I want the cover image on the left to be a rounded corners picture. I did the following, but it didn’t work. Thanks!

    getItem(var subject) {
    var row = Container(
      margin: EdgeInsets.all(8.0),
      child: Row(
        children: <Widget>[
          Container(
            width: 100.0,
            height: 150.0,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(8.0)),
              color: Colors.redAccent,
            ),
            child: Image.network(
              subject['images']['large'],
              height: 150.0,
              width: 100.0,
            ),
          ),
        ],
      ),
    );
    return Card(
      color: Colors.blueGrey,
      child: row,
    );
  }

as follows

enter image description here


Use ClipRRect it will work perfectly.

ClipRRect(
    borderRadius: BorderRadius.circular(8.0),
    child: Image.network(
        subject['images']['large'],
        height: 150.0,
        width: 100.0,
    ),
)

You can also use CircleAvatar, which comes with flutter

CircleAvatar(
  radius: 20,
  backgroundImage: NetworkImage('https://via.placeholder.com/140x100')
)

1. Circular image (without border)

enter image description here

  • Using CircleAvatar:

    CircleAvatar(
      radius: 48, // Image radius
      backgroundImage: NetworkImage('imageUrl'),
    )
    
  • Using ClipRRect:

    ClipOval(
      child: SizedBox.fromSize(
        size: Size.fromRadius(48), // Image radius
        child: Image.network('imageUrl', fit: BoxFit.cover),
      ),
    )
    

2. Circular image (with border)

enter image description here

  • Using CircleAvatar:

    CircleAvatar(
      radius: 56,
      backgroundColor: Colors.red,
      child: Padding(
        padding: const EdgeInsets.all(8), // Border radius
        child: ClipOval(child: Image.network('imageUrl')),
      ),
    )
    
  • Using ClipRRect:

    Container(
      padding: EdgeInsets.all(8), // Border width
      decoration: BoxDecoration(color: Colors.red, shape: BoxShape.circle),
      child: ClipOval(
        child: SizedBox.fromSize(
          size: Size.fromRadius(48), // Image radius
          child: Image.network('imageUrl', fit: BoxFit.cover),
        ),
      ),
    )
    

3. Rounded image (without border)

enter image description here

ClipRRect(
  borderRadius: BorderRadius.circular(20), // Image border
  child: SizedBox.fromSize(
    size: Size.fromRadius(48), // Image radius
    child: Image.network('imageUrl', fit: BoxFit.cover),
  ),
)

4. Rounded image (with border)

enter image description here

final borderRadius = BorderRadius.circular(20); // Image border

Container(
  padding: EdgeInsets.all(8), // Border width
  decoration: BoxDecoration(color: Colors.red, borderRadius: borderRadius),
  child: ClipRRect(
    borderRadius: borderRadius,
    child: SizedBox.fromSize(
      size: Size.fromRadius(48), // Image radius
      child: Image.network('imageUrl', fit: BoxFit.cover),
    ),
  ),
)

There are other ways, like using DecoratedBox but that would make the answer bit too long.


Try this instead, worked for me:

Container(
  width: 100.0,
  height: 150.0,
  decoration: BoxDecoration(
    image: DecorationImage(
        fit: BoxFit.cover, image: NetworkImage('Path to your image')),
    borderRadius: BorderRadius.all(Radius.circular(8.0)),
    color: Colors.redAccent,
  ),
),