Unverified Commit dc691304 authored by Viren Khatri's avatar Viren Khatri Committed by GitHub

changed Scrollbar to StatelessWidget (#87647)

parent 0f4e1db7
......@@ -91,7 +91,7 @@ const Duration _kScrollbarTimeToFade = Duration(milliseconds: 600);
/// * [CupertinoScrollbar], an iOS style scrollbar.
/// * [ListView], which displays a linear, scrollable list of children.
/// * [GridView], which displays a 2 dimensional, scrollable array of children.
class Scrollbar extends StatefulWidget {
class Scrollbar extends StatelessWidget {
/// Creates a material design scrollbar that by default will connect to the
/// closest Scrollable descendant of [child].
///
......@@ -169,39 +169,32 @@ class Scrollbar extends StatefulWidget {
/// {@macro flutter.widgets.Scrollbar.scrollbarOrientation}
final ScrollbarOrientation? scrollbarOrientation;
@override
State<Scrollbar> createState() => _ScrollbarState();
}
class _ScrollbarState extends State<Scrollbar> {
bool get _useCupertinoScrollbar => Theme.of(context).platform == TargetPlatform.iOS;
@override
Widget build(BuildContext context) {
if (_useCupertinoScrollbar) {
if (Theme.of(context).platform == TargetPlatform.iOS) {
return CupertinoScrollbar(
isAlwaysShown: widget.isAlwaysShown ?? false,
thickness: widget.thickness ?? CupertinoScrollbar.defaultThickness,
thicknessWhileDragging: widget.thickness ?? CupertinoScrollbar.defaultThicknessWhileDragging,
radius: widget.radius ?? CupertinoScrollbar.defaultRadius,
radiusWhileDragging: widget.radius ?? CupertinoScrollbar.defaultRadiusWhileDragging,
controller: widget.controller,
notificationPredicate: widget.notificationPredicate,
scrollbarOrientation: widget.scrollbarOrientation,
child: widget.child,
isAlwaysShown: isAlwaysShown ?? false,
thickness: thickness ?? CupertinoScrollbar.defaultThickness,
thicknessWhileDragging: thickness ?? CupertinoScrollbar.defaultThicknessWhileDragging,
radius: radius ?? CupertinoScrollbar.defaultRadius,
radiusWhileDragging: radius ?? CupertinoScrollbar.defaultRadiusWhileDragging,
controller: controller,
notificationPredicate: notificationPredicate,
scrollbarOrientation: scrollbarOrientation,
child: child,
);
}
return _MaterialScrollbar(
controller: widget.controller,
isAlwaysShown: widget.isAlwaysShown,
showTrackOnHover: widget.showTrackOnHover,
hoverThickness: widget.hoverThickness,
thickness: widget.thickness,
radius: widget.radius,
notificationPredicate: widget.notificationPredicate,
interactive: widget.interactive,
scrollbarOrientation: widget.scrollbarOrientation,
child: widget.child,
controller: controller,
isAlwaysShown: isAlwaysShown,
showTrackOnHover: showTrackOnHover,
hoverThickness: hoverThickness,
thickness: thickness,
radius: radius,
notificationPredicate: notificationPredicate,
interactive: interactive,
scrollbarOrientation: scrollbarOrientation,
child: child,
);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment