I am using below code in my flutter application with firestore as database backend, earlier the sliver effect was working fine, but when I re-installed the application and then again tested then I faced the below error upon re-launch of the application, how should I resolve it?
ERROR
A RenderViewport expected a child of type RenderSliver but received a child of type RenderErrorBox.
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
leading: IconButton(
icon: Icon(Icons.filter_1),
onPressed: () {
// Do something
}),
expandedHeight: 100.0,
floating: true,
pinned: false,
snap: true,
elevation: 50,
backgroundColor: Colors.pink,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Text('Title',
style: TextStyle(
color: Colors.white,
fontSize: 16.0,
)),
background: Image.network(
'https://images.pexels.com/photos/443356/pexels-photo-443356.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940',
fit: BoxFit.cover,
)),
),
StreamBuilder<QuerySnapshot>(
stream: query.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData){
return Center(child: Text("Loading"));
}
return SliverList(
delegate: new SliverChildBuilderDelegate(
(context, index) {
String itemTitle = snapshot.data.documents[index]['itemTitle'];
return CardItem(itemTitle:itemTitle );
},
childCount:
snapshot.hasData ? snapshot.data.documents.length : 0,
));
},
),
],
),
);