Home > OS >  Flutter List View Scrolling Only by Clicking on Edges
Flutter List View Scrolling Only by Clicking on Edges

Time:08-03

I'm Having a List view in my app, and the problem is it does not scroll when touching the middle of the list view but only when touching the edges of the list.

enter image description here

and here is my View Code.

 Widget build(BuildContext context) {
    const horizontalPadding = EdgeInsets.symmetric(horizontal: 10);
    final controller = Get.put(UnitsListController());
    return Scaffold(
      appBar: AppBar(
      ),
      body: Padding(
        padding: horizontalPadding,
        child: GetX<UnitsListController>(
            builder: (controller) {
              return controller.isBusy.value
              ?const Center(
                child: CircularProgressIndicator(
                  backgroundColor: Colors.grey,
                  color: Colors.blue,
                  strokeWidth: 5,
                ),
              ): ListView.builder(
                shrinkWrap: true,
                itemCount: controller.unitsList.length,
                itemBuilder: (context, index) {
                  var item = controller.unitsList[index];

                  String address ='${item.country},${item.state},${item.area},${item.block},${item.plot},'
                      '${item.lane},${item.buildingName},${item.buildingNumber}';
                  return GestureDetector(
                    onTap: () {
                      controller.selectedUnit = item;
                      controller.onUnitTap();
                    },
                    child:  AppUnitCard(
                    type: item.type,
                    address: address,
                    rooms: item.roomsNum??0,
                    rent: item.rent,
                    bathrooms: item.bathsNum,
                    space: item.unitSpace,

                  ),
                  );
                },
              );
            }),
      ),
    );
  }

Note that i was wrapping the Scaffold body with a SingleChildScrollView and removed it both ways it didn't work.

CodePudding user response:

Wrap the listview with a SingleChildScrollView and add NeverScrollableScrollPhysics to the listview

SingleChildScrollView (
 child : ListView.builder(
                shrinkWrap: true,
                physics : NeverScrollableScrollPhysics()
      )
   ),

CodePudding user response:

ListView doesn't scroll when wrapped by Column & SingleChildScrollView on all the browsers on Android. For further details and code examples check the link:

https://github.com/flutter/flutter/issues/80794#issuecomment-823961805

If this link didn't help you can find more information on this link:

All solutions for the problem

  • Related