Rounded Corners Image in Flutter

后端 未结 15 1965
难免孤独
难免孤独 2020-12-22 18:34

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 wor

相关标签:
15条回答
  • 2020-12-22 19:01

    Use ClipRRect it will resolve your problem.

          ClipRRect(
                  borderRadius: BorderRadius.all(Radius.circular(10.0)),
                  child: Image.network(
                    Constant.SERVER_LINK + model.userProfilePic,
                    fit: BoxFit.cover,
                  ),
                ),
    
    0 讨论(0)
  • 2020-12-22 19:03

    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,
      ),
    ),
    
    0 讨论(0)
  • 2020-12-22 19:03

    you can use ClipRRect like this :

      Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(25),
                        child: Image.asset(
                          'assets/images/pic13.jpeg',
                          fit: BoxFit.cover,
                        ),
                      ),
                    )
    

    you can set your radius, or user for only for topLeft or bottom left like :

    Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: ClipRRect(
                    borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(25)
                    ,bottomLeft: Radius.circular(25)),
                    child: Image.asset(
                      'assets/images/pic13.jpeg',
                      fit: BoxFit.cover,
                    ),
                  ),
                )
    
    0 讨论(0)
  • 2020-12-22 19:05

    Use this Way in this circle image is also working + you have preloader also for network image:

    new ClipRRect(
         borderRadius: new BorderRadius.circular(30.0),
         child: FadeInImage.assetNetwork(
              placeholder:'asset/loader.gif',
              image: 'Your Image Path',
          ),
        )
    
    0 讨论(0)
  • 2020-12-22 19:06

    You can use CircleAvatar Widget with radius:

    CircleAvatar(
                 radius: 50.0,
                 backgroundImage: AssetImage("assets/img1.jpeg"),
                ),
    
    0 讨论(0)
  • 2020-12-22 19:07

    Use ClipRRect with set image property of fit: BoxFit.fill

    ClipRRect(
              borderRadius: new BorderRadius.circular(10.0),
              child: Image(
                fit: BoxFit.fill,
                image: AssetImage('images/image.png'),
                width: 100.0,
                height: 100.0,
              ),
            ),
    
    0 讨论(0)
提交回复
热议问题