overscroll_behavior.dart 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 buildOverscrollIndicator(
  8. BuildContext context, Widget child, ScrollableDetails details) {
  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: details.direction,
  21. color: Theme.of(context).colorScheme.secondary,
  22. );
  23. case TargetPlatform.linux:
  24. // TODO: Handle this case.
  25. break;
  26. case TargetPlatform.macOS:
  27. // TODO: Handle this case.
  28. break;
  29. case TargetPlatform.windows:
  30. // TODO: Handle this case.
  31. break;
  32. }
  33. return child;
  34. }
  35. }