一个RenderShrinkWrappingViewport期望一个类型为RenderSliver的子端口,但是收到了一



我是新的扑动和firebase集成。我正在尝试构建连接到firestore的移动应用程序。

我正试图在我的移动应用程序中使用分页firestore。但我得到的错误消息说"一个RenderShrinkWrappingViewport期望类型为RenderSliver的子,但收到类型为RenderFlex的子">

这是我的代码

Widget build(BuildContext context) {
return Container(
child: StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('vendors')
.orderBy('shopName').snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapShot) {
if (snapShot.data == null) return CircularProgressIndicator();
if(snapShot.hasData){
print("error");
}
return Padding(
padding: EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RefreshIndicator(
child: PaginateFirestore(
bottomLoader: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
Theme.of(context).primaryColor),
),
header: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding:
const EdgeInsets.only(left: 8, right: 8, top: 20),
child: Text(
'All Nearby Stores',
style: TextStyle(
fontWeight: FontWeight.w900, fontSize: 18),
),
),
Padding(
padding:
const EdgeInsets.only(left: 8, right: 8, top: 20),
child: Text(
'Find quality products near you',
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 12,
color: Colors.grey),
),
),
],
),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilderType: PaginateBuilderType.listView,
itemBuilder: (index, context, document) => Padding(
padding: const EdgeInsets.all(4),
child: Container(
width: MediaQuery.of(context).size.width,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 120,
height: 100,
child: Card(
child: ClipRRect(
borderRadius: BorderRadius.circular(4),
child: Image.network(
document['imageUrl'],
fit: BoxFit.fill,
),
),
),
),
SizedBox(
width: 10,
),
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 35,
child: Text(
document['shopName'],
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
SizedBox(
height: 3,
),
Container(
width:
MediaQuery.of(context).size.width - 250,
child: Text(
document['location'],
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold),
)),
SizedBox(
height: 3,
),
Row(
children: [
Icon(
Icons.star,
size: 12,
color: Colors.grey,
),
SizedBox(
width: 4,
),
Text(
'3.2',
style: TextStyle(
fontSize: 10,
),
)
],
)
],
)
],
),
),
),
query: FirebaseFirestore.instance
.collection('vendors')
.orderBy('shopName'),
listeners: [
refreshChangeListener,
],
footer: Padding(
padding: const EdgeInsets.only(top: 30),
child: Container(
child: Stack(
children: [
Center(
child: Text(
"that's al folks",
style: TextStyle(color: Colors.grey),
),
),
Image.asset(
"image/city.png",
),
Positioned(
right: 10,
top: 80,
child: Container(
width: 100,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Made By : ',
style: TextStyle(color: Colors.black),
),
Text(
"IZZILLY TEAM",
style: TextStyle(
fontWeight: FontWeight.bold,
letterSpacing: 2,
color: Colors.grey),
)
],
),
))
],
),
),
),
),
onRefresh: ()async{
refreshChangeListener.refreshed = true;
},
)
],
),
);
},
),
);
}

有谁知道如何解决这个错误吗?

谢谢

根据相关问题,您的代码应该做的事情是将页眉和页脚小部件(以及其他框型小部件)包装在SliverToBoxAdapter中。您可以参考这个问题和这个Github问题来查看类似您的示例代码。例如,根据相关问题,包装您的标题将看起来像这样:

header: SliverToBoxAdapter(
child: Column(
...
),
),

你还应该在你的问题中附加日志和错误细节,就像我链接的github问题和相关问题中存在的那些。将更多的光照耀到导致错误的细节。

相关内容

最新更新