Home > Mobile >  scrollable homepage doesn't scroll well
scrollable homepage doesn't scroll well

Time:12-29

Flexible(
 child: StreamBuilder(
      stream: ref.snapshots(),
      builder: (context,AsyncSnapshot<QuerySnapshot> snapshot){
      if(snapshot.hasError){
          return Center(
          child: Text("Error: ${snapshot.error}"),
        );
       }
      //here what widget should i add
     return Scrollbar(
        child: GridView.builder(
        shrinkWrap: true,
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 2,
              mainAxisSpacing: 15,
              crossAxisSpacing: 15,
              childAspectRatio: 2/3,
     ),

i don't know why the scrollable on homepage can't work well start from the gridView i can't touch on that section to perform the scroll action

CodePudding user response:

When you put two scroll view inside each other that happened, you need to disable second scroll view 's physics, try change your code to this:

 Scrollbar(
    child: GridView.builder(
      shrinkWrap: true,
      physics: NeverScrollableScrollPhysics(), // <--- add this
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
        mainAxisSpacing: 15,
        crossAxisSpacing: 15,
        childAspectRatio: 2 / 3,
      ),
    ),
  ),

CodePudding user response:

You have two scrollable widgets together, so they're clashing. so set physics: const NeverScrollableScrollPhysics on your GridView.

Scrollbar(
      child: GridView.builder(
        shrinkWrap: true,
        physics: const NeverScrollableScrollPhysics(), 
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        ),
      ),
    )
  • Related