Search code examples
flutterdartheightflutter-card

How to change height of a card in flutter


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),
)

Solution

  • To modify the width or height of a card you can wrap it in a Container Widget and provide height and/or width properties to it.

    Please see below your code wrapped with a container set with height at 500:

    Container(
      height: 500,
      child: 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),
      ),
    ),