flutterflutter-widgetflutter-imageflutter-assetimage

Flutter. Image rounded borders not working


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.


Solution

  • 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