Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions packages/flutter/lib/src/cupertino/scrollbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ const double _kScrollbarCrossAxisMargin = 3.0;
/// {@tool dartpad}
/// When [thumbVisibility] is true, the scrollbar thumb will remain visible without the
/// fade animation. This requires that a [ScrollController] is provided to controller,
/// or that the [PrimaryScrollController] is available. [isAlwaysShown] is
/// deprecated in favor of `thumbVisibility`.
/// or that the [PrimaryScrollController] is available.
///
/// ** See code in examples/api/lib/cupertino/scrollbar/cupertino_scrollbar.1.dart **
/// {@end-tool}
Expand Down Expand Up @@ -82,20 +81,10 @@ class CupertinoScrollbar extends RawScrollbar {
this.radiusWhileDragging = defaultRadiusWhileDragging,
ScrollNotificationPredicate? notificationPredicate,
super.scrollbarOrientation,
@Deprecated(
'Use thumbVisibility instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
)
bool? isAlwaysShown,
}) : assert(thickness < double.infinity),
assert(thicknessWhileDragging < double.infinity),
assert(
isAlwaysShown == null || thumbVisibility == null,
'Scrollbar thumb appearance should only be controlled with thumbVisibility, '
'isAlwaysShown is deprecated.'
),
super(
thumbVisibility: isAlwaysShown ?? thumbVisibility ?? false,
thumbVisibility: thumbVisibility ?? false,
fadeDuration: _kScrollbarFadeDuration,
timeToFade: _kScrollbarTimeToFade,
pressDuration: const Duration(milliseconds: 100),
Expand Down
55 changes: 5 additions & 50 deletions packages/flutter/lib/src/material/scrollbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,12 @@ class Scrollbar extends StatelessWidget {
this.notificationPredicate,
this.interactive,
this.scrollbarOrientation,
@Deprecated(
'Use thumbVisibility instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
)
this.isAlwaysShown,
@Deprecated(
'Use ScrollbarThemeData.trackVisibility to resolve based on the current state instead. '
'This feature was deprecated after v3.4.0-19.0.pre.',
)
this.showTrackOnHover,
@Deprecated(
'Use ScrollbarThemeData.thickness to resolve based on the current state instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
)
this.hoverThickness,
}) : assert(
thumbVisibility == null || isAlwaysShown == null,
'Scrollbar thumb appearance should only be controlled with thumbVisibility, '
'isAlwaysShown is deprecated.'
);
});

/// {@macro flutter.widgets.Scrollbar.child}
final Widget child;
Expand All @@ -131,20 +117,8 @@ class Scrollbar extends StatelessWidget {
/// If the thumb visibility is related to the scrollbar's material state,
/// use the global [ScrollbarThemeData.thumbVisibility] or override the
/// sub-tree's theme data.
///
/// Replaces deprecated [isAlwaysShown].
final bool? thumbVisibility;

/// {@macro flutter.widgets.Scrollbar.isAlwaysShown}
///
/// To show the scrollbar thumb based on a [MaterialState], use
/// [ScrollbarThemeData.thumbVisibility].
@Deprecated(
'Use thumbVisibility instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
)
final bool? isAlwaysShown;

/// {@macro flutter.widgets.Scrollbar.trackVisibility}
///
/// If this property is null, then [ScrollbarThemeData.trackVisibility] of
Expand Down Expand Up @@ -172,21 +146,6 @@ class Scrollbar extends StatelessWidget {
)
final bool? showTrackOnHover;

/// The thickness of the scrollbar when a hover state is active and
/// [showTrackOnHover] is true.
///
/// If this property is null, then [ScrollbarThemeData.thickness] of
/// [ThemeData.scrollbarTheme] is used to resolve a thickness. If that is also
/// null, the default value is 12.0 pixels.
///
/// This is deprecated, use [ScrollbarThemeData.thickness] to resolve based on
/// the current state instead.
@Deprecated(
'Use ScrollbarThemeData.thickness to resolve based on the current state instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
)
final double? hoverThickness;

/// The thickness of the scrollbar in the cross axis of the scrollable.
///
/// If null, the default value is platform dependent. On [TargetPlatform.android],
Expand Down Expand Up @@ -216,7 +175,7 @@ class Scrollbar extends StatelessWidget {
Widget build(BuildContext context) {
if (Theme.of(context).platform == TargetPlatform.iOS) {
return CupertinoScrollbar(
thumbVisibility: isAlwaysShown ?? thumbVisibility ?? false,
thumbVisibility: thumbVisibility ?? false,
thickness: thickness ?? CupertinoScrollbar.defaultThickness,
thicknessWhileDragging: thickness ?? CupertinoScrollbar.defaultThicknessWhileDragging,
radius: radius ?? CupertinoScrollbar.defaultRadius,
Expand All @@ -229,10 +188,9 @@ class Scrollbar extends StatelessWidget {
}
return _MaterialScrollbar(
controller: controller,
thumbVisibility: isAlwaysShown ?? thumbVisibility,
thumbVisibility: thumbVisibility,
trackVisibility: trackVisibility,
showTrackOnHover: showTrackOnHover,
hoverThickness: hoverThickness,
thickness: thickness,
radius: radius,
notificationPredicate: notificationPredicate,
Expand All @@ -250,7 +208,6 @@ class _MaterialScrollbar extends RawScrollbar {
super.thumbVisibility,
super.trackVisibility,
this.showTrackOnHover,
this.hoverThickness,
super.thickness,
super.radius,
ScrollNotificationPredicate? notificationPredicate,
Expand All @@ -264,7 +221,6 @@ class _MaterialScrollbar extends RawScrollbar {
);

final bool? showTrackOnHover;
final double? hoverThickness;

@override
_MaterialScrollbarState createState() => _MaterialScrollbarState();
Expand All @@ -280,7 +236,7 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> {
late bool _useAndroidScrollbar;

@override
bool get showScrollbar => widget.thumbVisibility ?? _scrollbarTheme.thumbVisibility?.resolve(_states) ?? _scrollbarTheme.isAlwaysShown ?? false;
bool get showScrollbar => widget.thumbVisibility ?? _scrollbarTheme.thumbVisibility?.resolve(_states) ?? false;

@override
bool get enableGestures => widget.interactive ?? _scrollbarTheme.interactive ?? !_useAndroidScrollbar;
Expand Down Expand Up @@ -370,8 +326,7 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> {
MaterialStateProperty<double> get _thickness {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.hovered) && _trackVisibility.resolve(states)) {
return widget.hoverThickness
?? _scrollbarTheme.thickness?.resolve(states)
return _scrollbarTheme.thickness?.resolve(states)
?? _kScrollbarThicknessWithTrack;
}
// The default scrollbar thickness is smaller on mobile.
Expand Down
34 changes: 1 addition & 33 deletions packages/flutter/lib/src/material/scrollbar_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,15 @@ class ScrollbarThemeData with Diagnosticable {
this.mainAxisMargin,
this.minThumbLength,
this.interactive,
@Deprecated(
'Use thumbVisibility instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
)
this.isAlwaysShown,
@Deprecated(
'Use ScrollbarThemeData.trackVisibility to resolve based on the current state instead. '
'This feature was deprecated after v3.4.0-19.0.pre.',
)
this.showTrackOnHover,
}) : assert(
isAlwaysShown == null || thumbVisibility == null,
'Scrollbar thumb appearance should only be controlled with thumbVisibility, '
'isAlwaysShown is deprecated.'
);
});

/// Overrides the default value of [Scrollbar.thumbVisibility] in all
/// descendant [Scrollbar] widgets.
///
/// Replaces deprecated [isAlwaysShown].
final MaterialStateProperty<bool?>? thumbVisibility;

/// Overrides the default value of [Scrollbar.thickness] in all
Expand All @@ -86,16 +75,6 @@ class ScrollbarThemeData with Diagnosticable {
)
final bool? showTrackOnHover;

/// Overrides the default value of [Scrollbar.isAlwaysShown] in all
/// descendant [Scrollbar] widgets.
///
/// Deprecated in favor of [thumbVisibility].
@Deprecated(
'Use thumbVisibility instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
)
final bool? isAlwaysShown;

/// Overrides the default value of [Scrollbar.interactive] in all
/// descendant [Scrollbar] widgets.
final bool? interactive;
Expand Down Expand Up @@ -169,12 +148,6 @@ class ScrollbarThemeData with Diagnosticable {
double? crossAxisMargin,
double? mainAxisMargin,
double? minThumbLength,
@Deprecated(
'Use thumbVisibility instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
)
bool? isAlwaysShown,

@Deprecated(
'Use ScrollbarThemeData.trackVisibility to resolve based on the current state instead. '
'This feature was deprecated after v3.4.0-19.0.pre.',
Expand All @@ -186,7 +159,6 @@ class ScrollbarThemeData with Diagnosticable {
thickness: thickness ?? this.thickness,
trackVisibility: trackVisibility ?? this.trackVisibility,
showTrackOnHover: showTrackOnHover ?? this.showTrackOnHover,
isAlwaysShown: isAlwaysShown ?? this.isAlwaysShown,
interactive: interactive ?? this.interactive,
radius: radius ?? this.radius,
thumbColor: thumbColor ?? this.thumbColor,
Expand All @@ -212,7 +184,6 @@ class ScrollbarThemeData with Diagnosticable {
thickness: MaterialStateProperty.lerp<double?>(a?.thickness, b?.thickness, t, lerpDouble),
trackVisibility: MaterialStateProperty.lerp<bool?>(a?.trackVisibility, b?.trackVisibility, t, _lerpBool),
showTrackOnHover: _lerpBool(a?.showTrackOnHover, b?.showTrackOnHover, t),
isAlwaysShown: _lerpBool(a?.isAlwaysShown, b?.isAlwaysShown, t),
interactive: _lerpBool(a?.interactive, b?.interactive, t),
radius: Radius.lerp(a?.radius, b?.radius, t),
thumbColor: MaterialStateProperty.lerp<Color?>(a?.thumbColor, b?.thumbColor, t, Color.lerp),
Expand All @@ -230,7 +201,6 @@ class ScrollbarThemeData with Diagnosticable {
thickness,
trackVisibility,
showTrackOnHover,
isAlwaysShown,
interactive,
radius,
thumbColor,
Expand All @@ -254,7 +224,6 @@ class ScrollbarThemeData with Diagnosticable {
&& other.thickness == thickness
&& other.trackVisibility == trackVisibility
&& other.showTrackOnHover == showTrackOnHover
&& other.isAlwaysShown == isAlwaysShown
&& other.interactive == interactive
&& other.radius == radius
&& other.thumbColor == thumbColor
Expand All @@ -272,7 +241,6 @@ class ScrollbarThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<MaterialStateProperty<double?>>('thickness', thickness, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<bool?>>('trackVisibility', trackVisibility, defaultValue: null));
properties.add(DiagnosticsProperty<bool>('showTrackOnHover', showTrackOnHover, defaultValue: null));
properties.add(DiagnosticsProperty<bool>('isAlwaysShown', isAlwaysShown, defaultValue: null));
properties.add(DiagnosticsProperty<bool>('interactive', interactive, defaultValue: null));
properties.add(DiagnosticsProperty<Radius>('radius', radius, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color?>>('thumbColor', thumbColor, defaultValue: null));
Expand Down
Loading