如何在颤动中更改卡的高度

时间:2019-09-26 10:48:39

标签: flutter dart height flutter-card

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

2 个答案:

答案 0 :(得分:4)

时间在移动,希望您喜欢: 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),
  ),
),

答案 1 :(得分:2)

要修改卡片的宽度或高度,可以将其包装在Container Widget中,并为其提供height和/或width属性。

请在下面的代码中看到一个用高度为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),
      ),
    ),