1+ import 'package:flutter/gestures.dart' ;
12import 'package:flutter/widgets.dart' ;
23
34class BouncingScrollBehavior extends ScrollBehavior {
45 // Disable overscroll glow.
56 @override
7+ Widget buildOverscrollIndicator (
8+ BuildContext context, Widget child, ScrollableDetails details) {
9+ return child;
10+ }
11+
612 Widget buildViewportChrome (
713 BuildContext context, Widget child, AxisDirection axisDirection) {
814 return child;
@@ -17,18 +23,27 @@ class BouncingScrollBehavior extends ScrollBehavior {
1723
1824class BouncingScrollWrapper extends StatelessWidget {
1925 final Widget child;
26+ final bool dragWithMouse;
2027
21- const BouncingScrollWrapper ({Key ? key, required this .child})
28+ const BouncingScrollWrapper (
29+ {Key ? key, required this .child, this .dragWithMouse = false })
2230 : super (key: key);
2331
24- static Widget builder (BuildContext context, Widget child) {
25- return BouncingScrollWrapper (child: child);
32+ static Widget builder (BuildContext context, Widget child,
33+ {bool dragWithMouse = false }) {
34+ return BouncingScrollWrapper (child: child, dragWithMouse: dragWithMouse);
2635 }
2736
2837 @override
2938 Widget build (BuildContext context) {
3039 return ScrollConfiguration (
31- behavior: BouncingScrollBehavior (),
40+ behavior: BouncingScrollBehavior ().copyWith (
41+ dragDevices: dragWithMouse
42+ ? {
43+ PointerDeviceKind .touch,
44+ PointerDeviceKind .mouse,
45+ }
46+ : null ),
3247 child: child,
3348 );
3449 }
@@ -37,8 +52,8 @@ class BouncingScrollWrapper extends StatelessWidget {
3752class ClampingScrollBehavior extends ScrollBehavior {
3853 // Disable overscroll glow.
3954 @override
40- Widget buildViewportChrome (
41- BuildContext context, Widget child, AxisDirection axisDirection ) {
55+ Widget buildOverscrollIndicator (
56+ BuildContext context, Widget child, ScrollableDetails details ) {
4257 return child;
4358 }
4459
@@ -51,18 +66,27 @@ class ClampingScrollBehavior extends ScrollBehavior {
5166
5267class ClampingScrollWrapper extends StatelessWidget {
5368 final Widget child;
69+ final bool dragWithMouse;
5470
55- const ClampingScrollWrapper ({Key ? key, required this .child})
71+ const ClampingScrollWrapper (
72+ {Key ? key, required this .child, this .dragWithMouse = false })
5673 : super (key: key);
5774
58- static Widget builder (BuildContext context, Widget child) {
59- return ClampingScrollWrapper (child: child);
75+ static Widget builder (BuildContext context, Widget child,
76+ {bool dragWithMouse = false }) {
77+ return ClampingScrollWrapper (child: child, dragWithMouse: dragWithMouse);
6078 }
6179
6280 @override
6381 Widget build (BuildContext context) {
6482 return ScrollConfiguration (
65- behavior: ClampingScrollBehavior (),
83+ behavior: ClampingScrollBehavior ().copyWith (
84+ dragDevices: dragWithMouse
85+ ? {
86+ PointerDeviceKind .touch,
87+ PointerDeviceKind .mouse,
88+ }
89+ : null ),
6690 child: child,
6791 );
6892 }
0 commit comments