簡體   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