ListView中的ExpansionTile-页面不滚动 [英] ExpansionTile inside ListView - page not scrolling

查看:114
本文介绍了ListView中的ExpansionTile-页面不滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临页面滚动问题.我正在显示每天分组的用户交易. 因此ExpansionTile中将包含多个项目.

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. 获取所有记录
  2. 获取天数并放入一个列表(天数列表)
  3. 在此列表(天列表)中加载带有for循环的主扩展图块
  4. 当我们进行循环时,当天进行交易并加载到另一个数组中
  5. 将子级绑定为ExpansionTile的子级.

我的视图加载正确,但是当我打开ExpansionTile的子项时,我无法滚动页面.请查看视频以更清楚地了解. https://drive.google.com/file/d/1EVETVRHx0vZqiGryrcxUR0klrEX8Y63G/view?usp = sharing

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

我的代码如下,

 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));
          }
        },
      ),
    );
  }

下面是buildBody函数.

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()),
      ],
    );
  }

下面是我如何带所有孩子并将其绑定到ExpansionTile中的方法.

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,
      );
    }
}

谢谢.

推荐答案

最后,我可以使用下面的链接给出的答案来解决这个问题.根据我的要求更改了我的代码,因为我的要求是80%相似.

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.

如何在Flutter中创建可扩展ListView

谢谢.

这篇关于ListView中的ExpansionTile-页面不滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆