overscroll_behavior.dart 834 B

1234567891011121314151617181920212223242526272829
  1. import 'package:flutter/material.dart';
  2. class OverScrollBehavior extends ScrollBehavior {
  3. final bool isShowLeading;
  4. final bool isShowTrailing;
  5. OverScrollBehavior({this.isShowLeading = true, this.isShowTrailing = true});
  6. @override
  7. Widget buildViewportChrome(
  8. BuildContext context, Widget child, AxisDirection axisDirection) {
  9. switch (getPlatform(context)) {
  10. case TargetPlatform.iOS:
  11. return child;
  12. case TargetPlatform.android:
  13. case TargetPlatform.fuchsia:
  14. return GlowingOverscrollIndicator(
  15. child: child,
  16. //不显示头部水波纹
  17. showLeading: false,
  18. //不显示尾部水波纹
  19. showTrailing: false,
  20. axisDirection: axisDirection,
  21. color: Theme.of(context).accentColor,
  22. );
  23. }
  24. return child;
  25. }
  26. }