Home > Back-end >  Flutter. Image rounded borders not working
Flutter. Image rounded borders not working

Time:12-19

I'm trying to make rounded corners of image. Here is my code:

                   ClipRRect(
                        borderRadius: BorderRadius.circular(14),
                        child: Image.asset(
                          "assets/images/test.png"                         
                        ))

Everything works well, but when I try to fit the image into a container with a fixed height and width, the rounded borders stop working. Here is my code:

         LimitedBox(
              maxWidth: 95,
              maxHeight: 95,
              child: ClipRRect(
                    borderRadius: BorderRadius.circular(14),
                    child: Image.asset(
                      "assets/images/test.png"                        
                    ),
              ),
            )

Why is this happening, please help me.

CodePudding user response:

Let's try with background image

Container(
              height: 120.0,
              width: 120.0,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(14),
                image: DecorationImage(
                  image: AssetImage(
                      'assets/images/test.jpg'),
                  fit: BoxFit.fill,
                ),

              ),
            )

output:

enter image description here

  • Related