【问题标题】:How can I remove/disable vertical PageView top/bottom color - scroll glow - Flutter如何删除/禁用垂直 PageView 顶部/底部颜色 - 滚动发光 - 颤振
【发布时间】:2023-04-09 14:46:01
【问题描述】:

有谁知道是否有办法删除用户到达项目末尾时出现的 PageView 颜色? 这是一张描述我的意思的图片 Click here

PageView.builder(
                    physics: NeverScrollableScrollPhysics(),
                    scrollDirection: Axis.vertical,
                    controller: _controller,
                    itemCount: 4,
                    itemBuilder: (BuildContext context, int index) {
                      _isValid = false;
                      return [
                          SizedBox.expand(...),
                          SizedBox.expand(...),
                          SizedBox.expand(...),
                          SizedBox.expand(...),
                        ][index];
                    },
                  )

我在这里找到了完整而正确的答案:How to remove scroll glow?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    此效果由ScrollBehavior 提供。您需要提供您的自定义ScrollBehavior 并将其包装在ScrollConfiguration 中。

    class CustomScrollBehavior extends ScrollBehavior {
     @override
      Widget buildViewportChrome(
         BuildContext context, Widget child, AxisDirection axisDirection) {
         return child;
      }
    }
    

    移除 PageView 中的效果

    ScrollConfiguration(
      behavior: CustomScrollBehavior(),
      child: PageView.builder(
        ...
      ),
    )
    

    【讨论】:

      【解决方案2】:

      在新的flutter v2(sdk 2.8.1)之后,以上一个对我不起作用,

      NotificationListener<OverscrollIndicatorNotification>(
        onNotification: (overscroll) {
         overscroll.disallowIndicator();
          return true;
         },
      child: SingleChildScrollView(
      
       )
      )
      

      【讨论】: