@@ -37,15 +37,11 @@ class BouncingScrollWrapper extends StatelessWidget {
3737
3838 @override
3939 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- }
4740 return ScrollConfiguration (
48- behavior: scrollBehavior,
41+ behavior: dragWithMouse
42+ ? const BouncingScrollBehavior ()
43+ .copyWith (dragDevices: {PointerDeviceKind .mouse})
44+ : const BouncingScrollBehavior (),
4945 child: child,
5046 );
5147 }
@@ -82,15 +78,11 @@ class ClampingScrollWrapper extends StatelessWidget {
8278
8379 @override
8480 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- }
9281 return ScrollConfiguration (
93- behavior: scrollBehavior,
82+ behavior: dragWithMouse
83+ ? const ClampingScrollBehavior ()
84+ .copyWith (dragDevices: {PointerDeviceKind .mouse})
85+ : const ClampingScrollBehavior (),
9486 child: child,
9587 );
9688 }
@@ -100,6 +92,24 @@ class NoScrollbarBehavior extends ScrollBehavior {
10092 @override
10193 Widget buildScrollbar (
10294 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+ );
104114 }
105115}
0 commit comments