【问题标题】:How to set a GirdView hight to wrap its contant - Flutter Web如何设置 GridView 高度以包装其内容 - Flutter Web
【发布时间】:2021-08-29 15:32:31
【问题描述】:

在我的颤振网络应用程序中,我有 gird,它显示了它从 firebase firestore 获取数据的导师,但 gidviews 显示错误

RenderFlex children have non-zero flex but incoming height constraints are unbounded.

我已经厌倦了将它包装在一个扩展的小部件中但没有工作,当我将 gridview 包装在 sizedbox 中并设置它的高度时它工作正常,但我希望高度应该根据 girdview 中的项目是动态的。

girdview 在列表视图中。

这是我的代码

 StreamBuilder(
              stream: FirebaseFirestore.instance
                  .collection('consultants')
                  .snapshots(),
              builder: (BuildContext context,
                  AsyncSnapshot<QuerySnapshot> snapshot) {
                if (!snapshot.hasData) {
                  return Center(
                    child: ProgressBar(loading: true),
                  );
                } else {
                  return GridView.count(
                    crossAxisCount: 4,
                    childAspectRatio: 0.8,
                    children: snapshot.data.docs.map((documents) {
                      return ConsultantCard(
                        name: documents['name'],
                        profession: documents['profession'],
                        shortDesc: documents['shortDesc'],
                        countryCode: documents['countryCode'],
                        imageUrl: documents['imageUrl'],
                        rating: documents['rating'],
                        ratingsNum: documents['ratingsNum'],
                        fees: documents['fees'],
                        verified: documents['verified'],
                        popular: documents['popular'],
                        freeTrial: documents['freeTrial'],
                        languages: documents['languages'],
                      );
                    }).toList(),
                  );
                }
              }),

【问题讨论】:

  • 收缩包装:真

标签: firebase flutter google-cloud-firestore gridview flutter-web


【解决方案1】:

shrinkWrap: true 这就是您在 gridView 中所需要的

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-27
    相关资源
    最近更新 更多