繁体   English   中英

Flutter - 如何指定卡片高度

[英]Flutter - how to specific Card height

class CardContent extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.all(8.0),
      height: 40,
      child: Card(
        semanticContainer: true,
        clipBehavior: Clip.antiAliasWithSaveLayer,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(12.0),
        ),
        child: Column(
          children: [
            Padding(
              padding: const EdgeInsets.all(12.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'Test Campaign',
                    style: TextStyle(
                      color: Theme.of(context).primaryColor,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  LineButton(
                    onPress: () => null,
                    label: 'View',
                    height: 30,
                    backgroundColor: Colors.grey[300],
                  )
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

我有这段代码可以输出这个。 现在这部分只是选项卡内的内容。

在此处输入图像描述

如您所见,卡一直向下。 我希望那张卡片的高度约为 50 像素。 我怎样才能做到这一点?

您只需将容器包装为 sniglechildScrollView。 我希望它会起作用,我测试了它

SingleChildScrollView(
        padding: EdgeInsets.all(8),
        child: Column(
          children: [
            Container(
              margin: const EdgeInsets.all(8.0),
              height: 80,
              child: Card(
                semanticContainer: true,
                clipBehavior: Clip.antiAliasWithSaveLayer,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(12.0),
                ),
                child: Column(
                  children: [
                    Padding(
                      padding: const EdgeInsets.all(12.0),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            'Test Campaign',
                            style: TextStyle(
                              color: Theme.of(context).primaryColor,
                              fontWeight: FontWeight.bold,
                            ),
                          ),
                           LineButton(
                    onPress: () => null,
                    label: 'View',
                    height: 30,
                    backgroundColor: Colors.grey[300],
                  )
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
        
          ],
        ),
      )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM