Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading