I am using a gridview.builder to show my fetched data from firestore. But the builder is not showing my products. I checked out the complete code of firebase fetch and everything is working. Still I am unable to show data using builder. Here is the code. Please help
main.dart
if (state is SearchScreenDefaultState) {
return GridView.builder(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 2,
childAspectRatio: 1 / 1.3,
),
itemCount: state.snapshot.docs.length,
itemBuilder: (context, index) {
return productCard(
product: ProductModel.fromJson(
state.snapshot.docs[index].data()),
);
},
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
CodePudding user response:
I think the problem is with gridview builder, check the update code once and let me know if this works for you. Please update your code for more information.
if (state is SearchScreenDefaultState) {
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1 / 1.3,
),
itemCount: state.snapshot.docs.length,
itemBuilder: (context, index) {
return productCard(
product: ProductModel.fromJson(
state.snapshot.docs[index].data()),
);
},
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}