skip to Main Content
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

2

Answers


  1. 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,
          ),
        ),
      ),
    
    Login or Signup to reply.
  2. 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(
            ),
          ),
        )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search