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),
)
How to change height of a card in flutter
Asked Answered
You can wrap it with a Container: Container(height: 100, child: Card( semanticContainer: true, clipBehavior: Clip.antiAliasWithSaveLayer, child: Image.network( 'placeimg.com/640/480/any',fit: BoxFit.fill,), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0), ), elevation: 5, margin: EdgeInsets.all(10), )) –
Ditchwater
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),
),
),
If 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. –
Slipshod
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),
),
),
© 2022 - 2024 — McMap. All rights reserved.