justy
justy

Reputation: 413

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

Upvotes: 41

Views: 126285

Answers (2)

Stéphane COUGET
Stéphane COUGET

Reputation: 221

Time is moving, prefer you that: https://api.flutter.dev/flutter/widgets/SizedBox-class.html

SizedBox(
  height: double.infinity,
  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),
  ),
),

Upvotes: 17

J. S.
J. S.

Reputation: 9625

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

Upvotes: 83

Related Questions