如何设置 GridView 高度以包裹其内容 - Flutter Web
How to set a GirdView hight to wrap its contant - Flutter Web
在我的 flutter web 应用程序中,我有 gird 显示它从 firebase firestore 获取数据的指导者,但 gidviews 显示错误
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
我已经厌倦了将它包装在一个扩展的小部件中,但没有用,当我将 gridview 包装在 sizedbox 中并设置它的高度时,它工作正常,但我希望高度应该是基于 girdview 中的项目的动态.
girdview 在 listview 中。
这是我的代码
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(),
);
}
}),
shrinkWrap: true
这就是您在 gridView
中所需要的
在我的 flutter web 应用程序中,我有 gird 显示它从 firebase firestore 获取数据的指导者,但 gidviews 显示错误
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
我已经厌倦了将它包装在一个扩展的小部件中,但没有用,当我将 gridview 包装在 sizedbox 中并设置它的高度时,它工作正常,但我希望高度应该是基于 girdview 中的项目的动态.
girdview 在 listview 中。
这是我的代码
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(),
);
}
}),
shrinkWrap: true
这就是您在 gridView