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),
)
Asked
Active
Viewed 1.1e+01k times
35
-
You can wrap it with a Container: Container(height: 100, 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), )) – Stel Sep 26 '19 at 11:01
2 Answers
79
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),
),
),

J. S.
- 8,905
- 2
- 34
- 44
-
10If the Container is nested in another widget, the width & height may not get applied as expected. You can [overcome this by wrapping that Container in an Align widget](https://stackoverflow.com/a/54717843/3291390). – Stack Underflow Jun 02 '20 at 19:48
15
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),
),
),

ferluis
- 122
- 1
- 7

Stéphane COUGET
- 181
- 1
- 3