buildViewportChrome method

  1. @override
Widget buildViewportChrome(
  1. BuildContext context,
  2. Widget child,
  3. AxisDirection axisDirection
)
override

Wraps the given widget, which scrolls in the given AxisDirection.

For example, on Android, this method wraps the given widget with a GlowingOverscrollIndicator to provide visual feedback when the user overscrolls.

This method is deprecated. Use ScrollBehavior.buildOverscrollIndicator instead.

Implementation

@override
Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) {
  switch (getPlatform(context)) {
    case TargetPlatform.iOS:
      return child;
    case TargetPlatform.android:
    case TargetPlatform.fuchsia:
      return GlowingOverscrollIndicator(
        child: child,
        //不显示头部水波纹
        showLeading: false,
        //不显示尾部水波纹
        showTrailing: false,
        axisDirection: axisDirection,
        color: Theme.of(context).accentColor,
      );
    default:
      break;
  }
  return null;
}