首页 > 解决方案 > Flutter中基于动态数据扩展卡片高度

问题描述

我需要根据动态数据设置卡片的高度。我的卡片没有显示卡片中的全部内容。

Card(
            child: Container(
              padding: EdgeInsets.all(7.0),
              child: Wrap(
                direction: Axis.horizontal,
                spacing: 200.0, // gap between adjacent chips
                runSpacing: 0.0,
                children: <Widget>[
                  Container(
                      height: 40.0,
                      decoration: new BoxDecoration(
                        color: Colors.grey[800],
                        borderRadius: new BorderRadius.only(
                          topLeft: const Radius.circular(10.0),
                          topRight: const Radius.circular(10.0),
                        ),
                      ),
                      child: Column(
                        children: <Widget>[
                          Align(
                            child: Container(
                              padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
                              margin: const EdgeInsets.all(8.0),
                              child: Text(
                                contactUs.title,
                                style: Theme.of(context).textTheme.headline,
                              ),
                            ),
                          ),
                        ],
                      )),
                  Container(
                    padding: EdgeInsets.all(3.0),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Container(
                          child: Container(
                            child: Column(
                              children: <Widget>[
                                subtitlesLength > 0
                                    ? _listSubtitleSection(contactUs.subtitles)
                                    : Container(),
                              ],
                            ),
                          ),
                        ),
                        Container(
                          child: Column(
                            children: <Widget>[
                              contactUs.addresses.length > 0
                                  ? _listAddressSection(contactUs.addresses)
                                  : Container(),
                            ],
                          ),
                        ),
                        contactUs.email != ''
                            ? Container(
                                child: GestureDetector(
                                  child: Text(
                                    'Email: ' + contactUs.email,
                                    style: new TextStyle(
                                      color: Theme.of(context).primaryColor,
                                      height: 1.5,
                                      decoration: TextDecoration.underline,
                                    ),
                                  ),
                                  onTap: () {
                                    _launchURL(contactUs.email);
                                  },
                                ),
                              )
                            : Container(),
                        Container(
                          alignment: Alignment.centerLeft,
                          margin: const EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 0.0),
                          child: Container(
                            child: Column(
                              children: <Widget>[
                                contactUs.links.length > 0
                                    ? _listLinksSection(contactUs.links)
                                    : Container(),
                              ],
                            ),
                          ),
                        ),
                        Container(
                          child: Column(
                            children: <Widget>[
                              Divider(
                                color: Theme.of(context).accentColor,
                              ),
                              FlatButton(
                                  color: Colors.white,
                                  child: Row(
                                    children: <Widget>[
                                      Icon(Icons.place,
                                          color:
                                              Theme.of(context).primaryColor),
                                      Text(
                                        'Show on maps',
                                        style: TextStyle(
                                            color:
                                                Theme.of(context).primaryColor),
                                      ),
                                    ],
                                  ),
                                  onPressed: () {
                                    launchMap(contactUs.map);
                                  }),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          )

我将一半的数据加载到卡中,未显示剩余内容。我试图在卡内放置容器的高度,但这不起作用。我需要帮助来解决这个问题。任何帮助表示赞赏。提前致谢。

标签: dartflutter

解决方案


删除 listView 构建器的 itemExtent 属性解决了这个问题。


推荐阅读