Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change height of a card in flutter

Tags:

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),
)
like image 539
justy Avatar asked Sep 26 '19 10:09

justy


People also ask

How do you resize card widget in flutter?

Customizing Card As it doesn't provide option to adjust width or height, the easiest way to set the size is by wrapping it inside a Container or a SizedBox widget. Then, specify the desired width and height of the Container or SizedBox .

How do you increase image height in flutter?

To set specific height for Image widget in Flutter Application, set height property of Image object with required double value.

How do you change the width and height of text in flutter?

The font size can be set by manipulating the fontSize property of the TextStyle class. The line-height can be adjusted by using the height property of the TextStyle class. When height is non-null, the line-height of the span of text will be a multiple of fontSize and be exactly fontSize * height logical pixels tall.


2 Answers

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),
  ),
),
like image 105
João Soares Avatar answered Oct 24 '22 20:10

João Soares


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),
  ),
),
like image 24
Stéphane COUGET Avatar answered Oct 24 '22 21:10

Stéphane COUGET