Rounded Corners Image in Flutter

后端 未结 15 1964
难免孤独
难免孤独 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: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,
                    ),
                  ),
                )
    

提交回复
热议问题