Flutter How to create Card with background Image?

后端 未结 4 1686
青春惊慌失措
青春惊慌失措 2020-12-14 01:51

I\'m trying to create a Card with an Image as a background. The problem is, the Image overflows the Card, so the Corners of the don\'t show up.

I need to either set

4条回答
  •  攒了一身酷
    2020-12-14 02:46

    Other Way Without using - ClipRRect Widget - is To set semanticContainer: true, of Card Widget.

    Example Code as Below:

    Card(
              semanticContainer: true,
              clipBehavior: Clip.antiAliasWithSaveLayer,
              child: Image.network(
                'https://placeimg.com/640/480/any',
                fit: BoxFit.fill,
              ),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(10.0),
              ),
              elevation: 5,
              margin: EdgeInsets.all(10),
            ),
    

    Output:

提交回复
热议问题