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); ...@@ -91,7 +91,7 @@ const Duration _kScrollbarTimeToFade = Duration(milliseconds: 600);
/// * [CupertinoScrollbar], an iOS style scrollbar. /// * [CupertinoScrollbar], an iOS style scrollbar.
/// * [ListView], which displays a linear, scrollable list of children. /// * [ListView], which displays a linear, scrollable list of children.
/// * [GridView], which displays a 2 dimensional, scrollable array 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 /// Creates a material design scrollbar that by default will connect to the
/// closest Scrollable descendant of [child]. /// closest Scrollable descendant of [child].
/// ///
...@@ -169,39 +169,32 @@ class Scrollbar extends StatefulWidget { ...@@ -169,39 +169,32 @@ class Scrollbar extends StatefulWidget {
/// {@macro flutter.widgets.Scrollbar.scrollbarOrientation} /// {@macro flutter.widgets.Scrollbar.scrollbarOrientation}
final ScrollbarOrientation? scrollbarOrientation; final ScrollbarOrientation? scrollbarOrientation;
@override
State<Scrollbar> createState() => _ScrollbarState();
}
class _ScrollbarState extends State<Scrollbar> {
bool get _useCupertinoScrollbar => Theme.of(context).platform == TargetPlatform.iOS;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_useCupertinoScrollbar) { if (Theme.of(context).platform == TargetPlatform.iOS) {
return CupertinoScrollbar( return CupertinoScrollbar(
isAlwaysShown: widget.isAlwaysShown ?? false, isAlwaysShown: isAlwaysShown ?? false,
thickness: widget.thickness ?? CupertinoScrollbar.defaultThickness, thickness: thickness ?? CupertinoScrollbar.defaultThickness,
thicknessWhileDragging: widget.thickness ?? CupertinoScrollbar.defaultThicknessWhileDragging, thicknessWhileDragging: thickness ?? CupertinoScrollbar.defaultThicknessWhileDragging,
radius: widget.radius ?? CupertinoScrollbar.defaultRadius, radius: radius ?? CupertinoScrollbar.defaultRadius,
radiusWhileDragging: widget.radius ?? CupertinoScrollbar.defaultRadiusWhileDragging, radiusWhileDragging: radius ?? CupertinoScrollbar.defaultRadiusWhileDragging,
controller: widget.controller, controller: controller,
notificationPredicate: widget.notificationPredicate, notificationPredicate: notificationPredicate,
scrollbarOrientation: widget.scrollbarOrientation, scrollbarOrientation: scrollbarOrientation,
child: widget.child, child: child,
); );
} }
return _MaterialScrollbar( return _MaterialScrollbar(
controller: widget.controller, controller: controller,
isAlwaysShown: widget.isAlwaysShown, isAlwaysShown: isAlwaysShown,
showTrackOnHover: widget.showTrackOnHover, showTrackOnHover: showTrackOnHover,
hoverThickness: widget.hoverThickness, hoverThickness: hoverThickness,
thickness: widget.thickness, thickness: thickness,
radius: widget.radius, radius: radius,
notificationPredicate: widget.notificationPredicate, notificationPredicate: notificationPredicate,
interactive: widget.interactive, interactive: interactive,
scrollbarOrientation: widget.scrollbarOrientation, scrollbarOrientation: scrollbarOrientation,
child: widget.child, 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