子滚动条会影响父滚动条吗? [英] Child Scrollbar affects parent scrollbar?

查看:259
本文介绍了子滚动条会影响父滚动条吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的滚动条位于较高的层次,子滚动条位于树的下方几层.滚动孩子时,父母也会滚动.仅滚动条显示并在父级中移动.相反,这不会发生.我试过用手势检测器包裹孩子,但是没有用.顺便说一句,这是网站

I have Scrollbar at a high level and child scrollbar a few levels down the tree. When scrolling the child, the parent scrolls too. Just the scrollbar shows and moves in the parent. This does not happen the other way around. I've tried wrapping the child in a gesture detector, that didn't work. BTW this is Web

这是父级布局小部件(子级将用于渲染子级):

This is the parent layout widget(child is where the children will render):

Scrollbar(
    controller: layoutScrollController,
    child: SingleChildScrollView(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          if(title != null) Container(
            height: 67,
            width: MediaQuery.of(context).size.width,
            decoration: BoxDecoration(
                color:Theme.of(context).brightness == Brightness.dark ? GatheredThemeColors.light[850] : Colors.white,
                border: Border(
                    bottom: BorderSide(
                        color: Theme.of(context).brightness == Brightness.dark ? GatheredThemeColors.light[800] : GatheredThemeColors.light[200],
                        width: 1
                    )
                )
            ),
            padding: EdgeInsets.all(20),
            child: Text(title,style: Theme.of(context).textTheme.headline1,),
          ),
          Container(
            padding: EdgeInsets.all(20),
            constraints: BoxConstraints(minHeight: 200),
            child: child,
          ),
        ],
      ),
    ),
  );
}

在下图中,报告"区域是导致父级滚动的子级.查找ReportList.报告列表是一个ListView小部件.

In the below image the "Reports" area is the child that is causing the parent to scroll. Look for ReportList. Report list is a ListView widget.

推荐答案

这是一种解决方法,我找不到参考文献,但看起来像是flutter团队正在解决此问题.

This is a work around, I can't find the reference, but it looks like the flutter team looks to fix this.

是的.这样包装滚动条:

Here it is. Wrap your scrollbar like this:

NotificationListener<ScrollNotification>(
    onNotification: (notification) => true,
    child: Scrollbar()
)

这篇关于子滚动条会影响父滚动条吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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