** Can you please help**. I/m having trouble scrolling with my product grid page, unable to scroll down to the end, I'm only able to see about 14 items of the 100 items I have listed. Can someone please help me on how I fix this issue to have unlimited scrolling. I believe the issue is with List businessLogic.

 Here's my code: 



 import 'package:flutter/material.dart';
 import 'package:flutter_e_commerce_app/ads_helper.dart';
 import 'package:provider/provider.dart';

 import '../../Models/product.dart';
 import 'components/products_grid_item.dart';
  // ignore: must_be_immutable
 class ProductsGrid extends StatelessWidget {
 // String? categoryId;
  List<Product>? products;

  ProductsGrid({
  // this.categoryId,
  this.products,
   Key? key,
   }) : super(key: key);



  @override
  Widget build(BuildContext context) {
  return Scaffold(
  appBar: AppBar(
    title: Text(''),
    ),
  body: Container(
    child: renderScrollArea(context),
   ),
   );
   }

   List<Widget> businessLogic(BuildContext context) {
   List<Widget> temp = [];
   for (var i = 1; i < products!.length+1; i++) {
   if (i % 12 == 1) {

    int next=i+1;
    if(next<products!.length){


      temp.add(renderGrids(context,i,next));
    }
    else{
      temp.add(renderGrids(context,i,-1));
    }

    }
    if (i  == 6) {
    int next=i+1;
    if(next<products!.length){


      temp.add(renderGrids(context,i,next));
    }
    else{
      temp.add(renderGrids(context,i,-1));
    }
    temp.add(renderLists(context,products![i]));
    }


    }

   return temp;
   }

   Widget renderScrollArea(BuildContext context) {
   final scrollableArea = CustomScrollView(
   slivers: businessLogic(context),

    // Below lines are neglected as we have more complex requirement
    // slivers: <Widget>[
   //   renderGrids(context),
    //   renderLists(context),
    //   renderGrids(context),
   //   renderLists(context),
   // ],
  );
  return scrollableArea;
   }

   Widget renderLists(BuildContext context,Product i) {
    final lists = SliverList(
  delegate: SliverChildListDelegate(
    [
      AdFeed(i),
    ],
    ),
     );
    return lists;
    }

    Widget renderGrids(BuildContext context,i, int next) {


    final grids = SliverGrid(
    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
    crossAxisCount: 2,

    ),
    delegate: SliverChildListDelegate(
    [
      contentView(products![i]),
      next!=-1?contentView(products![next]):SizedBox(height: 0,width: 0,),
    ],
    ),
    );
     return grids;
    }


     Widget contentView(Product i) {
     return   ChangeNotifierProvider.value(
     value: i,
     child:Container(

      child: Column(

          children: <Widget>[
            ProductsGridItem(

              key: ValueKey(i.id),
              // can be done with product in ChangeNotifierProvider.value
              // productId: products[index].id,
              // productName: products[index].name,
              // imageUrl: products[index].images,
              // productColor: products[index].color,
              // productPrice: products[index].price,
              // categoryId: products[index].categoryId,
              // productLikes: products[index].likes,
              // productTotal: products[index].Total,
              // imageUrl: 'assets/images/mobile.png',
              // productName: 'Mobile Oppo A5',
              // productColor: 'Color Blue',
              // productPrice: 3.00,
            ),
          ]
          )),

          );

          }


          }
0

There are 0 best solutions below