【问题标题】:Child Scrollbar affects parent scrollbar?子滚动条影响父滚动条?
【发布时间】:2020-07-20 19:45:11
【问题描述】:

我在高层有滚动条,在树的下面有几个级别的子滚动条。当滚动孩子时,父母也滚动。只是滚动条在父级中显示和移动。这不会反过来发生。我尝试将孩子包裹在手势检测器中,但没有成功。顺便说一句,这是网络

这是父布局小部件(子是子渲染的地方):

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

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

【问题讨论】:

  • 你能提供一些代码吗?您是否已经与SingleChildScrollView 合作过?
  • 代码量会太多。如前所述,父母和孩子之间的分离是几个层次。让我看看我是否可以建立一个例子
  • 你能给你的reportsList 一个shrinkWrap: true, 看看会发生什么吗?
  • 已经有一个

标签: flutter flutter-web flutter-scrollbar


【解决方案1】:

这是一个变通方法,我找不到参考,但看起来颤振团队希望解决这个问题。

来了。像这样包裹你的滚动条:

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

【讨论】:

    猜你喜欢
    • 2012-12-17
    • 2011-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-26
    • 2017-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多