@@ -37,15 +37,11 @@ class BouncingScrollWrapper extends StatelessWidget {
37
37
38
38
@override
39
39
Widget build (BuildContext context) {
40
- ScrollBehavior scrollBehavior = const BouncingScrollBehavior ();
41
- if (dragWithMouse) {
42
- // If mouse dragging is desired, add it to the drag devices.
43
- scrollBehavior = scrollBehavior.copyWith (
44
- dragDevices: scrollBehavior.dragDevices..add (PointerDeviceKind .mouse),
45
- );
46
- }
47
40
return ScrollConfiguration (
48
- behavior: scrollBehavior,
41
+ behavior: dragWithMouse
42
+ ? const BouncingScrollBehavior ()
43
+ .copyWith (dragDevices: {PointerDeviceKind .mouse})
44
+ : const BouncingScrollBehavior (),
49
45
child: child,
50
46
);
51
47
}
@@ -82,15 +78,11 @@ class ClampingScrollWrapper extends StatelessWidget {
82
78
83
79
@override
84
80
Widget build (BuildContext context) {
85
- ScrollBehavior scrollBehavior = const ClampingScrollBehavior ();
86
- if (dragWithMouse) {
87
- // If mouse dragging is desired, add it to the drag devices.
88
- scrollBehavior = scrollBehavior.copyWith (
89
- dragDevices: scrollBehavior.dragDevices..add (PointerDeviceKind .mouse),
90
- );
91
- }
92
81
return ScrollConfiguration (
93
- behavior: scrollBehavior,
82
+ behavior: dragWithMouse
83
+ ? const ClampingScrollBehavior ()
84
+ .copyWith (dragDevices: {PointerDeviceKind .mouse})
85
+ : const ClampingScrollBehavior (),
94
86
child: child,
95
87
);
96
88
}
@@ -100,6 +92,24 @@ class NoScrollbarBehavior extends ScrollBehavior {
100
92
@override
101
93
Widget buildScrollbar (
102
94
BuildContext context, Widget child, ScrollableDetails details) {
103
- return child; // This prevents the ListView from showing a scrollbar.
95
+ return child;
96
+ }
97
+ }
98
+
99
+ class NoScrollbarWrapper extends StatelessWidget {
100
+ final Widget child;
101
+
102
+ const NoScrollbarWrapper ({super .key, required this .child});
103
+
104
+ static Widget builder (BuildContext context, Widget child) {
105
+ return NoScrollbarWrapper (child: child);
106
+ }
107
+
108
+ @override
109
+ Widget build (BuildContext context) {
110
+ return ScrollConfiguration (
111
+ behavior: NoScrollbarBehavior (),
112
+ child: child,
113
+ );
104
114
}
105
115
}
0 commit comments