简体   繁体   English

我如何设置卡片的高度并使其灵活?

[英]How I can set height for Card and make in flexible?

I want set minimal height to screen bottom for my film decription card, and resizing and sroll it when description is big.我想为我的电影描述卡设置屏幕底部的最小高度,并在描述很大时调整大小并滚动它。 I try to do like this, but when discription is small, card getting smaller and seems so bad.我尝试这样做,但是当描述很小时,卡片变得越来越小并且看起来很糟糕。

_screenHalf = (MediaQuery.of(context).size.height - AppBar().preferredSize.height) / 2;

   Widget _buildFilmDescriptionPage() {
    return Hero(
      tag: '$name',
      child: Container(
        width: double.infinity,
        decoration: BoxDecoration(
          image: DecorationImage(
              image: ExactAssetImage(image),
              fit: BoxFit.cover,
              alignment: Alignment.topCenter),
        ),
        child: _buildFilmDescriptionCard()
      ),
    );
  }

  ListView _buildFilmDescriptionCard() {
    return ListView(
          children: <Widget>[
             Card(
                elevation: 5,
                clipBehavior: Clip.hardEdge,              
                margin: EdgeInsets.only(top: _screenHalf),
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.vertical(
                      top: Radius.circular(20)
                    )
                ),
                child: Column(
                    children: <Widget>[
                      Container(
                        margin: const EdgeInsets.only(
                            top: 5, bottom: 5, left: 10, right: 10),
                        child: Text(
                          name,
                          style: TextStyle(
                            fontSize: 18,
                            color: Colors.black,
                          ),
                        ),
                      ),
                      Container(
                        margin: const EdgeInsets.only(
                            top: 5, bottom: 5, left: 10, right: 10),
                        child: Text(
                          date,
                          style: TextStyle(
                            fontSize: 14,
                            color: Colors.black,
                          ),
                        ),
                      ),
                      Container(
                          margin: const EdgeInsets.only(
                              top: 5, bottom: 5, left: 10, right: 10),
                          child: Text(
                            description,
                            style: TextStyle(
                              fontSize: 14,
                              color: Colors.black,
                            ),
                          ),
                        ),
                    ],
                  ),
              ),
          ],
        );
  }

在此处输入图像描述

I want set minimal height to screen bottom for my film decription card, and resizing and sroll it when description is big.我想为我的电影描述卡设置屏幕底部的最小高度,并在描述很大时调整大小并滚动它。 I try to do like this, but when discription is small, card getting smaller and seems so bad.我尝试这样做,但是当描述很小时,卡片变得越来越小并且看起来很糟糕。

_screenHalf = (MediaQuery.of(context).size.height - AppBar().preferredSize.height) / 2;

   Widget _buildFilmDescriptionPage() {
    return Hero(
      tag: '$name',
      child: Container(
        width: double.infinity,
        decoration: BoxDecoration(
          image: DecorationImage(
              image: ExactAssetImage(image),
              fit: BoxFit.cover,
              alignment: Alignment.topCenter),
        ),
        child: _buildFilmDescriptionCard()
      ),
    );
  }

  ListView _buildFilmDescriptionCard() {
    return ListView(
          children: <Widget>[
             Card(
                elevation: 5,
                clipBehavior: Clip.hardEdge,              
                margin: EdgeInsets.only(top: _screenHalf),
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.vertical(
                      top: Radius.circular(20)
                    )
                ),
                child: Column(
                    children: <Widget>[
                      Container(
                        margin: const EdgeInsets.only(
                            top: 5, bottom: 5, left: 10, right: 10),
                        child: Text(
                          name,
                          style: TextStyle(
                            fontSize: 18,
                            color: Colors.black,
                          ),
                        ),
                      ),
                      Container(
                        margin: const EdgeInsets.only(
                            top: 5, bottom: 5, left: 10, right: 10),
                        child: Text(
                          date,
                          style: TextStyle(
                            fontSize: 14,
                            color: Colors.black,
                          ),
                        ),
                      ),
                      Container(
                          margin: const EdgeInsets.only(
                              top: 5, bottom: 5, left: 10, right: 10),
                          child: Text(
                            description,
                            style: TextStyle(
                              fontSize: 14,
                              color: Colors.black,
                            ),
                          ),
                        ),
                    ],
                  ),
              ),
          ],
        );
  }

在此处输入图像描述

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

相关问题 Flutter,如何设置具有最大高度300的灵活高度的项目列表的高度? - Flutter, how can i set the height of list of items with flexible height with max height 300? 如何根据内容扩展卡片高度? - How can I make a Card height extend based on content? 在 FIutter 中:登录和注册都有一个屏幕,当我在它们之间切换时,我未能使卡的高度灵活 - In FIutter : have one screen for both login and sign up, and i failed to make the card flexible in height when i switch between them 我怎样才能制作与我拥有的容器和卡片高度相匹配的物品 - how can I make items that match the height of the container and card that I have 如何让InViewNotifierList返回的Container高度灵活 - How to make the height of the Container returned by InViewNotifierList flexible Flutter - 如何设置 TabBar 的高度? - Flutter - how can i set the height of a TabBar? 如何在 Flutter 上面的灵活行中设置文本的宽度? - How can I set the width of a text based in the flexible row above in Flutter? flutter - 如何让我的应用栏在灵活的应用栏的同时充当材料搜索小部件 - flutter - How can I make my appbar act as material search widget while being flexible app bar 如何在 flutter 中制作更好的卡片 UI 间距 - How can I make a better Card UI spacing in flutter 如何在颤动中制作游戏卡动画 - how can I make game card animation in flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM