微信交流群

老孟公众号

# GlowingOverscrollIndicator

GlowingOverscrollIndicator 是Android平台ListView列表滑动到底部时在滑动出现的水波纹效果,此控件配合ScrollNotification使用。

案例:在IOS平台上也使用此效果

ScrollConfiguration(
  behavior: MyScrollBehavior(),
  child: ListView.builder(
    shrinkWrap: true,
    itemBuilder: (BuildContext context, int index) {
      return Text('Item$index');
    },
    itemExtent: 50,
    itemCount: 50,
  ),
)
1
2
3
4
5
6
7
8
9
10
11

MyScrollBehavior定义如下:

class MyScrollBehavior extends ScrollBehavior {
  
  Widget buildViewportChrome(
      BuildContext context, Widget child, AxisDirection axisDirection) {
    return GlowingOverscrollIndicator(
      child: child,
      axisDirection: axisDirection,
      color: Colors.blue,
    );
  }

  
  ScrollPhysics getScrollPhysics(BuildContext context) {
    return ClampingScrollPhysics();
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

GlowingOverscrollIndicator