Home > front end >  How can I box fit an image network in a container that has border radius
How can I box fit an image network in a container that has border radius

Time:10-13

how can I box fit an image network within the container with a border radius

Container(
    width: 100,
    height: 100,
    child: Image.network(
      snapshot.data!,
      fit: BoxFit.cover,
    ),
),

CodePudding user response:

ClipRRect(
    borderRadius: BorderRadius.circular(8.0),
    child: Container(
        height: 100.0,
        width: 100.0,
        child: Image.network(
        snapshot.data!,
        height: 100.0,
        width: 100.0,
    ),)
)

CodePudding user response:

ClipRRect(
    borderRadius: BorderRadius.circular(8.0),
 
        child: Image.network(
        snapshot.data!,
        height: 100.0,
        width: 100.0,
    ),
)

CodePudding user response:

While you are using Container with overriding clipBehavior and call decoration

Container(
  width: 100,
  height: 100,
  clipBehavior: Clip.hardEdge, //default is none
  decoration: BoxDecoration(
    borderRadius: BorderRadius.circular(12.0),
  ),
  child: Image.network(
    "",
    fit: BoxFit.cover,
  ),
),

CodePudding user response:

Container(
    width: 100,
    height: 100,
    child: Image.network(
      snapshot.data!,
      fit: BoxFit.cover,
      width: 100,
      height: 100,
    ),
),

CodePudding user response:

Container(
          decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(10)),
          width: 100,
          height: 100,
          child: Image.network(
          snapshot.data!,
          fit: BoxFit.cover,
          ),),
  • Related