【问题标题】:How to change height of a card in flutter如何在颤动中改变卡片的高度
【发布时间】:2020-01-26 15:14:23
【问题描述】:
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),
)

【问题讨论】:

  • 你可以用一个 Container 来包装它:Container(height: 100, child: Card( semanticContainer: true, clipBehavior: Clip.antiAliasWithSaveLayer, child: Image.network( 'placeimg.com/640/480/any',fit: BoxFit.fill ,), 形状: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0), ), 高度: 5, 边距: EdgeInsets.all(10), ))

标签: flutter dart height flutter-card


【解决方案1】:

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

请在下面查看您的代码,该代码使用高度为 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),
  ),
),

【讨论】:

【解决方案2】:

时代在变,更喜欢你: 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),
  ),
),

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-22
    • 2019-05-19
    • 2019-12-31
    • 2020-12-29
    • 1970-01-01
    • 2020-10-03
    • 2021-11-21
    • 2020-12-23
    相关资源
    最近更新 更多