Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the grid items feels jittery, a little choppy while being scrolling #101

Open
yuvisingh01 opened this issue Jun 11, 2024 · 0 comments
Open

Comments

@yuvisingh01
Copy link

I have used layout grid for the grid view of product cards of my shopping app, but it makes the scroll laggy, It seems like It loads all the items of the grid unlike listview or grid view where only items in a view are only loaded which keeps the app lighter...

but here I see my app getting havier as the user scrolls, and at some stage, it even crashes the app, why is it so, is there anything I am doing wrong or it is bound to happen with layout grid widget.

below is the code snippet fo your reference..

int crossAxisCount = screenWidth > 600 ? 4 : 2;

Expanded(
child: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
debugPrint('tapped');
},
child: SingleChildScrollView(
controller: scrollController,
child: Column(
children: [
LayoutGrid(
columnSizes: [
for (var _ in List.generate(crossAxisCount, (_) => 1.fr))
1.fr, // Equal column sizes
],
rowSizes: [
// ignore: unused_local_variable
for (var product in productsList)
auto, // Self-sizing rows
],
children: [
...productsList.map((product) {
return GestureDetector(
onTap: () async {

                        // Navigate to the ProductDetailsScreen
                        Navigator.push(
                          context,
                          MaterialPageRoute(
                            builder: (context) => ProductDetailsScreen(
                              product: product,
                            ),
                          ),
                        );
                      },
                      child: ProductCardWidget(
                        product: product,
                        onAddToCart: () {
                          ShoppingScreenMethods.addToCart(
                              product, 'home', context, ref);
                        },
                      ),
                    );
                  })
                ],
              ),
             ],
          ),
        ),
      ),
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant