Skip to content

Commit a3ddead

Browse files
authored
Remove scrollbar deprecations isAlwaysShown and hoverThickness (flutter#127351)
The deprecated `[RawScrollbar/Scrollbar/CupertinoScrollbar/ScrollbarThemeData].isAlwaysShown` has expired and is removed in thi PR. Also, `Scrollbar.hoverThickness` is also removed after having expired. The replacement for `isAlwaysShown` is `thumbVisibility`. This deprecation was introduced in flutter#96957. The name change came from new behaviors like a track that is conditionally visible. Since the original API only referred to the thumb, the name was changed to reflect this intention. This change is supported by dart fix. � The replacement for `hoverThickness` is `ScrollbarThemeData.thickness`, which is a MaterialStateProperty that allows for the thickness to respond to multiple states including hover. This deprecation was introduced in flutter#97173. This change is not supported by dart fix. � Part of flutter#127042
1 parent 9a26346 commit a3ddead

File tree

9 files changed

+127
-322
lines changed

9 files changed

+127
-322
lines changed

packages/flutter/lib/src/cupertino/scrollbar.dart

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ const double _kScrollbarCrossAxisMargin = 3.0;
5353
/// {@tool dartpad}
5454
/// When [thumbVisibility] is true, the scrollbar thumb will remain visible without the
5555
/// fade animation. This requires that a [ScrollController] is provided to controller,
56-
/// or that the [PrimaryScrollController] is available. [isAlwaysShown] is
57-
/// deprecated in favor of `thumbVisibility`.
56+
/// or that the [PrimaryScrollController] is available.
5857
///
5958
/// ** See code in examples/api/lib/cupertino/scrollbar/cupertino_scrollbar.1.dart **
6059
/// {@end-tool}
@@ -82,20 +81,10 @@ class CupertinoScrollbar extends RawScrollbar {
8281
this.radiusWhileDragging = defaultRadiusWhileDragging,
8382
ScrollNotificationPredicate? notificationPredicate,
8483
super.scrollbarOrientation,
85-
@Deprecated(
86-
'Use thumbVisibility instead. '
87-
'This feature was deprecated after v2.9.0-1.0.pre.',
88-
)
89-
bool? isAlwaysShown,
9084
}) : assert(thickness < double.infinity),
9185
assert(thicknessWhileDragging < double.infinity),
92-
assert(
93-
isAlwaysShown == null || thumbVisibility == null,
94-
'Scrollbar thumb appearance should only be controlled with thumbVisibility, '
95-
'isAlwaysShown is deprecated.'
96-
),
9786
super(
98-
thumbVisibility: isAlwaysShown ?? thumbVisibility ?? false,
87+
thumbVisibility: thumbVisibility ?? false,
9988
fadeDuration: _kScrollbarFadeDuration,
10089
timeToFade: _kScrollbarTimeToFade,
10190
pressDuration: const Duration(milliseconds: 100),

packages/flutter/lib/src/material/scrollbar.dart

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,12 @@ class Scrollbar extends StatelessWidget {
9595
this.notificationPredicate,
9696
this.interactive,
9797
this.scrollbarOrientation,
98-
@Deprecated(
99-
'Use thumbVisibility instead. '
100-
'This feature was deprecated after v2.9.0-1.0.pre.',
101-
)
102-
this.isAlwaysShown,
10398
@Deprecated(
10499
'Use ScrollbarThemeData.trackVisibility to resolve based on the current state instead. '
105100
'This feature was deprecated after v3.4.0-19.0.pre.',
106101
)
107102
this.showTrackOnHover,
108-
@Deprecated(
109-
'Use ScrollbarThemeData.thickness to resolve based on the current state instead. '
110-
'This feature was deprecated after v2.9.0-1.0.pre.',
111-
)
112-
this.hoverThickness,
113-
}) : assert(
114-
thumbVisibility == null || isAlwaysShown == null,
115-
'Scrollbar thumb appearance should only be controlled with thumbVisibility, '
116-
'isAlwaysShown is deprecated.'
117-
);
103+
});
118104

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

138-
/// {@macro flutter.widgets.Scrollbar.isAlwaysShown}
139-
///
140-
/// To show the scrollbar thumb based on a [MaterialState], use
141-
/// [ScrollbarThemeData.thumbVisibility].
142-
@Deprecated(
143-
'Use thumbVisibility instead. '
144-
'This feature was deprecated after v2.9.0-1.0.pre.',
145-
)
146-
final bool? isAlwaysShown;
147-
148122
/// {@macro flutter.widgets.Scrollbar.trackVisibility}
149123
///
150124
/// If this property is null, then [ScrollbarThemeData.trackVisibility] of
@@ -172,21 +146,6 @@ class Scrollbar extends StatelessWidget {
172146
)
173147
final bool? showTrackOnHover;
174148

175-
/// The thickness of the scrollbar when a hover state is active and
176-
/// [showTrackOnHover] is true.
177-
///
178-
/// If this property is null, then [ScrollbarThemeData.thickness] of
179-
/// [ThemeData.scrollbarTheme] is used to resolve a thickness. If that is also
180-
/// null, the default value is 12.0 pixels.
181-
///
182-
/// This is deprecated, use [ScrollbarThemeData.thickness] to resolve based on
183-
/// the current state instead.
184-
@Deprecated(
185-
'Use ScrollbarThemeData.thickness to resolve based on the current state instead. '
186-
'This feature was deprecated after v2.9.0-1.0.pre.',
187-
)
188-
final double? hoverThickness;
189-
190149
/// The thickness of the scrollbar in the cross axis of the scrollable.
191150
///
192151
/// If null, the default value is platform dependent. On [TargetPlatform.android],
@@ -216,7 +175,7 @@ class Scrollbar extends StatelessWidget {
216175
Widget build(BuildContext context) {
217176
if (Theme.of(context).platform == TargetPlatform.iOS) {
218177
return CupertinoScrollbar(
219-
thumbVisibility: isAlwaysShown ?? thumbVisibility ?? false,
178+
thumbVisibility: thumbVisibility ?? false,
220179
thickness: thickness ?? CupertinoScrollbar.defaultThickness,
221180
thicknessWhileDragging: thickness ?? CupertinoScrollbar.defaultThicknessWhileDragging,
222181
radius: radius ?? CupertinoScrollbar.defaultRadius,
@@ -229,10 +188,9 @@ class Scrollbar extends StatelessWidget {
229188
}
230189
return _MaterialScrollbar(
231190
controller: controller,
232-
thumbVisibility: isAlwaysShown ?? thumbVisibility,
191+
thumbVisibility: thumbVisibility,
233192
trackVisibility: trackVisibility,
234193
showTrackOnHover: showTrackOnHover,
235-
hoverThickness: hoverThickness,
236194
thickness: thickness,
237195
radius: radius,
238196
notificationPredicate: notificationPredicate,
@@ -250,7 +208,6 @@ class _MaterialScrollbar extends RawScrollbar {
250208
super.thumbVisibility,
251209
super.trackVisibility,
252210
this.showTrackOnHover,
253-
this.hoverThickness,
254211
super.thickness,
255212
super.radius,
256213
ScrollNotificationPredicate? notificationPredicate,
@@ -264,7 +221,6 @@ class _MaterialScrollbar extends RawScrollbar {
264221
);
265222

266223
final bool? showTrackOnHover;
267-
final double? hoverThickness;
268224

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

282238
@override
283-
bool get showScrollbar => widget.thumbVisibility ?? _scrollbarTheme.thumbVisibility?.resolve(_states) ?? _scrollbarTheme.isAlwaysShown ?? false;
239+
bool get showScrollbar => widget.thumbVisibility ?? _scrollbarTheme.thumbVisibility?.resolve(_states) ?? false;
284240

285241
@override
286242
bool get enableGestures => widget.interactive ?? _scrollbarTheme.interactive ?? !_useAndroidScrollbar;
@@ -370,8 +326,7 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> {
370326
MaterialStateProperty<double> get _thickness {
371327
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
372328
if (states.contains(MaterialState.hovered) && _trackVisibility.resolve(states)) {
373-
return widget.hoverThickness
374-
?? _scrollbarTheme.thickness?.resolve(states)
329+
return _scrollbarTheme.thickness?.resolve(states)
375330
?? _kScrollbarThicknessWithTrack;
376331
}
377332
// The default scrollbar thickness is smaller on mobile.

packages/flutter/lib/src/material/scrollbar_theme.dart

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,15 @@ class ScrollbarThemeData with Diagnosticable {
4545
this.mainAxisMargin,
4646
this.minThumbLength,
4747
this.interactive,
48-
@Deprecated(
49-
'Use thumbVisibility instead. '
50-
'This feature was deprecated after v2.9.0-1.0.pre.',
51-
)
52-
this.isAlwaysShown,
5348
@Deprecated(
5449
'Use ScrollbarThemeData.trackVisibility to resolve based on the current state instead. '
5550
'This feature was deprecated after v3.4.0-19.0.pre.',
5651
)
5752
this.showTrackOnHover,
58-
}) : assert(
59-
isAlwaysShown == null || thumbVisibility == null,
60-
'Scrollbar thumb appearance should only be controlled with thumbVisibility, '
61-
'isAlwaysShown is deprecated.'
62-
);
53+
});
6354

6455
/// Overrides the default value of [Scrollbar.thumbVisibility] in all
6556
/// descendant [Scrollbar] widgets.
66-
///
67-
/// Replaces deprecated [isAlwaysShown].
6857
final MaterialStateProperty<bool?>? thumbVisibility;
6958

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

89-
/// Overrides the default value of [Scrollbar.isAlwaysShown] in all
90-
/// descendant [Scrollbar] widgets.
91-
///
92-
/// Deprecated in favor of [thumbVisibility].
93-
@Deprecated(
94-
'Use thumbVisibility instead. '
95-
'This feature was deprecated after v2.9.0-1.0.pre.',
96-
)
97-
final bool? isAlwaysShown;
98-
9978
/// Overrides the default value of [Scrollbar.interactive] in all
10079
/// descendant [Scrollbar] widgets.
10180
final bool? interactive;
@@ -169,12 +148,6 @@ class ScrollbarThemeData with Diagnosticable {
169148
double? crossAxisMargin,
170149
double? mainAxisMargin,
171150
double? minThumbLength,
172-
@Deprecated(
173-
'Use thumbVisibility instead. '
174-
'This feature was deprecated after v2.9.0-1.0.pre.',
175-
)
176-
bool? isAlwaysShown,
177-
178151
@Deprecated(
179152
'Use ScrollbarThemeData.trackVisibility to resolve based on the current state instead. '
180153
'This feature was deprecated after v3.4.0-19.0.pre.',
@@ -186,7 +159,6 @@ class ScrollbarThemeData with Diagnosticable {
186159
thickness: thickness ?? this.thickness,
187160
trackVisibility: trackVisibility ?? this.trackVisibility,
188161
showTrackOnHover: showTrackOnHover ?? this.showTrackOnHover,
189-
isAlwaysShown: isAlwaysShown ?? this.isAlwaysShown,
190162
interactive: interactive ?? this.interactive,
191163
radius: radius ?? this.radius,
192164
thumbColor: thumbColor ?? this.thumbColor,
@@ -212,7 +184,6 @@ class ScrollbarThemeData with Diagnosticable {
212184
thickness: MaterialStateProperty.lerp<double?>(a?.thickness, b?.thickness, t, lerpDouble),
213185
trackVisibility: MaterialStateProperty.lerp<bool?>(a?.trackVisibility, b?.trackVisibility, t, _lerpBool),
214186
showTrackOnHover: _lerpBool(a?.showTrackOnHover, b?.showTrackOnHover, t),
215-
isAlwaysShown: _lerpBool(a?.isAlwaysShown, b?.isAlwaysShown, t),
216187
interactive: _lerpBool(a?.interactive, b?.interactive, t),
217188
radius: Radius.lerp(a?.radius, b?.radius, t),
218189
thumbColor: MaterialStateProperty.lerp<Color?>(a?.thumbColor, b?.thumbColor, t, Color.lerp),
@@ -230,7 +201,6 @@ class ScrollbarThemeData with Diagnosticable {
230201
thickness,
231202
trackVisibility,
232203
showTrackOnHover,
233-
isAlwaysShown,
234204
interactive,
235205
radius,
236206
thumbColor,
@@ -254,7 +224,6 @@ class ScrollbarThemeData with Diagnosticable {
254224
&& other.thickness == thickness
255225
&& other.trackVisibility == trackVisibility
256226
&& other.showTrackOnHover == showTrackOnHover
257-
&& other.isAlwaysShown == isAlwaysShown
258227
&& other.interactive == interactive
259228
&& other.radius == radius
260229
&& other.thumbColor == thumbColor
@@ -272,7 +241,6 @@ class ScrollbarThemeData with Diagnosticable {
272241
properties.add(DiagnosticsProperty<MaterialStateProperty<double?>>('thickness', thickness, defaultValue: null));
273242
properties.add(DiagnosticsProperty<MaterialStateProperty<bool?>>('trackVisibility', trackVisibility, defaultValue: null));
274243
properties.add(DiagnosticsProperty<bool>('showTrackOnHover', showTrackOnHover, defaultValue: null));
275-
properties.add(DiagnosticsProperty<bool>('isAlwaysShown', isAlwaysShown, defaultValue: null));
276244
properties.add(DiagnosticsProperty<bool>('interactive', interactive, defaultValue: null));
277245
properties.add(DiagnosticsProperty<Radius>('radius', radius, defaultValue: null));
278246
properties.add(DiagnosticsProperty<MaterialStateProperty<Color?>>('thumbColor', thumbColor, defaultValue: null));

0 commit comments

Comments
 (0)