0

I am facing issue with page scrolling. I am showing users transactions grouped per day. so there will be multiple items inside ExpansionTile.

I am first taking days from database and then taking transactions done on that day . so below is how my page working

  1. take all records
  2. get days and put in one list (days list)
  3. load main expansion tiles with for loop in this list(days list)
  4. when we do for loop take transactions on that day and load in another array
  5. bind children list as children to ExpansionTile.

My view is loading properly , but when i open subitems of ExpansionTile , i am not able to scroll page. please check video for more clear understanding. https://drive.google.com/file/d/1EVETVRHx0vZqiGryrcxUR0klrEX8Y63G/view?usp=sharing

My code is given below ,

 Widget build(BuildContext context) {
    return new Scaffold(

      body: FutureBuilder(
        future: getTransactions(),
        builder: (context, snapshot) {
          if (!snapshot.hasData) {
            return Center(child: CircularProgressIndicator());
          } else if (feedItemsParent.isEmpty) {
            return noRecordsDialogue(context, 'No transactions record', '');
          } else if (feedItemsParent.length == 0) {
            return noRecordsDialogue(context, 'No transactions record', '');
          } else {
            return new ListView.builder(
                shrinkWrap: true,
                itemCount: feedItemsParent.length,
                itemBuilder: (BuildContext ctxt, int index) =>
                    buildBody(ctxt, index));
          }
        },
      ),
    );
  }

below is buildBody function.

Widget buildBody(BuildContext ctxt, int index) {
    return new custom.ExpansionTile(
      initiallyExpanded: true,
      trailing: new Container(width: 20),
      headerBackgroundColor: Color(0xFFeff0f1),
      title: Text(
        feedItemsParent[index].transactiondatesmall.toString(),
        style: TextStyle(
          fontSize: 16,
          color: Colors.black,
          fontWeight: FontWeight.bold,
        ),
      ),
      children: <Widget>[
        buildTransactionList(
            feedItemsParent[index].transactiondatesmall.toString()),
      ],
    );
  }

below is how i am taking all children and binding them inside ExpansionTile.

 buildTransactionList(dtCompare) {
    if (feedItems.length == 0) {
      return noRecordsDialogue(context, 'No transactions record', '');
    } else {
      List<UserTransaction> feedItemsChild = [];
      for (int j = 0; j < feedItems.length; j++) {
        if (feedItems[j].transactiondatesmall == dtCompare) {
          feedItemsChild.add(feedItems[j]);
        }
      }

      return ListView(
        padding: const EdgeInsets.only(bottom: 16.0),
        shrinkWrap: true,
        children: feedItemsChild,
      );
    }
}

Thanks in advance.

shruti tupkari
  • 1,149
  • 1
  • 6
  • 17

2 Answers2

1

Finally i am able to solve this using answers given in below link. Changed my code as per given in answer as my requirement was 80% similar.

How to create Expandable ListView in Flutter

Thank you.

shruti tupkari
  • 1,149
  • 1
  • 6
  • 17
-2

just add this code to ListView.Builder to solve this issue

physics: const NeverScrollableScrollPhysics()