Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

GridViewBuilder is not showing my fetched data

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(),
                );
              }

Error Screenshot

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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(),
                );
              }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading