Skip to content

Commit 5332295

Browse files
authored
Remove deprecated ScrollBehavior.buildViewportChrome (#111715)
1 parent 9e87a5b commit 5332295

File tree

10 files changed

+96
-50
lines changed

10 files changed

+96
-50
lines changed

packages/flutter/lib/fix_data.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,39 @@
1717

1818
version: 1
1919
transforms:
20+
# Changes made in https://github.com/flutter/flutter/pull/78588
21+
- title: "Migrate to 'buildOverscrollIndicator'"
22+
date: 2021-03-18
23+
element:
24+
uris: ['widgets.dart', 'material.dart', 'cupertino.dart']
25+
method: 'buildViewportChrome'
26+
inClass: 'ScrollBehavior'
27+
changes:
28+
- kind: 'rename'
29+
newName: 'buildOverscrollIndicator'
30+
31+
# Changes made in https://github.com/flutter/flutter/pull/78588
32+
- title: "Migrate to 'buildOverscrollIndicator'"
33+
date: 2021-03-18
34+
element:
35+
uris: ['material.dart']
36+
method: 'buildViewportChrome'
37+
inClass: 'MaterialScrollBehavior'
38+
changes:
39+
- kind: 'rename'
40+
newName: 'buildOverscrollIndicator'
41+
42+
# Changes made in https://github.com/flutter/flutter/pull/78588
43+
- title: "Migrate to 'buildOverscrollIndicator'"
44+
date: 2021-03-18
45+
element:
46+
uris: ['cupertino.dart']
47+
method: 'buildViewportChrome'
48+
inClass: 'CupertinoScrollBehavior'
49+
changes:
50+
- kind: 'rename'
51+
newName: 'buildOverscrollIndicator'
52+
2053
# Changes made in https://github.com/flutter/flutter/pull/111706
2154
- title: "Migrate to 'trackVisibility'"
2255
date: 2022-09-15

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ class CupertinoScrollBehavior extends ScrollBehavior {
480480

481481
@override
482482
ScrollPhysics getScrollPhysics(BuildContext context) {
483+
// When modifying this function, consider modifying the implementation in
484+
// the base class ScrollBehavior as well.
483485
if (getPlatform(context) == TargetPlatform.macOS) {
484486
return const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast);
485487
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ class MaterialScrollBehavior extends ScrollBehavior {
817817
@override
818818
Widget buildScrollbar(BuildContext context, Widget child, ScrollableDetails details) {
819819
// When modifying this function, consider modifying the implementation in
820-
// the base class as well.
820+
// the base class ScrollBehavior as well.
821821
switch (axisDirectionToAxis(details.direction)) {
822822
case Axis.horizontal:
823823
return child;
@@ -841,7 +841,7 @@ class MaterialScrollBehavior extends ScrollBehavior {
841841
@override
842842
Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) {
843843
// When modifying this function, consider modifying the implementation in
844-
// the base class as well.
844+
// the base class ScrollBehavior as well.
845845
late final AndroidOverscrollIndicator indicator;
846846
if (Theme.of(context).useMaterial3) {
847847
indicator = AndroidOverscrollIndicator.stretch;

packages/flutter/lib/src/widgets/scroll_configuration.dart

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -132,45 +132,6 @@ class ScrollBehavior {
132132
/// impossible to select text in scrollable containers and is not recommended.
133133
Set<PointerDeviceKind> get dragDevices => _kTouchLikeDeviceTypes;
134134

135-
/// Wraps the given widget, which scrolls in the given [AxisDirection].
136-
///
137-
/// For example, on Android, this method wraps the given widget with a
138-
/// [GlowingOverscrollIndicator] to provide visual feedback when the user
139-
/// overscrolls.
140-
///
141-
/// This method is deprecated. Use [ScrollBehavior.buildOverscrollIndicator]
142-
/// instead.
143-
@Deprecated(
144-
'Migrate to buildOverscrollIndicator. '
145-
'This feature was deprecated after v2.1.0-11.0.pre.',
146-
)
147-
Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) {
148-
switch (getPlatform(context)) {
149-
case TargetPlatform.iOS:
150-
case TargetPlatform.linux:
151-
case TargetPlatform.macOS:
152-
case TargetPlatform.windows:
153-
return child;
154-
case TargetPlatform.android:
155-
switch (androidOverscrollIndicator) {
156-
case AndroidOverscrollIndicator.stretch:
157-
return StretchingOverscrollIndicator(
158-
axisDirection: axisDirection,
159-
child: child,
160-
);
161-
case AndroidOverscrollIndicator.glow:
162-
continue glow;
163-
}
164-
glow:
165-
case TargetPlatform.fuchsia:
166-
return GlowingOverscrollIndicator(
167-
axisDirection: axisDirection,
168-
color: _kDefaultGlowColor,
169-
child: child,
170-
);
171-
}
172-
}
173-
174135
/// Applies a [RawScrollbar] to the child widget on desktop platforms.
175136
Widget buildScrollbar(BuildContext context, Widget child, ScrollableDetails details) {
176137
// When modifying this function, consider modifying the implementation in
@@ -193,11 +154,32 @@ class ScrollBehavior {
193154
/// Applies a [GlowingOverscrollIndicator] to the child widget on
194155
/// [TargetPlatform.android] and [TargetPlatform.fuchsia].
195156
Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) {
196-
// TODO(Piinks): Move implementation from buildViewportChrome here after
197-
// deprecation period
198157
// When modifying this function, consider modifying the implementation in
199158
// the Material and Cupertino subclasses as well.
200-
return buildViewportChrome(context, child, details.direction);
159+
switch (getPlatform(context)) {
160+
case TargetPlatform.iOS:
161+
case TargetPlatform.linux:
162+
case TargetPlatform.macOS:
163+
case TargetPlatform.windows:
164+
return child;
165+
case TargetPlatform.android:
166+
switch (androidOverscrollIndicator) {
167+
case AndroidOverscrollIndicator.stretch:
168+
return StretchingOverscrollIndicator(
169+
axisDirection: details.direction,
170+
child: child,
171+
);
172+
case AndroidOverscrollIndicator.glow:
173+
continue glow;
174+
}
175+
glow:
176+
case TargetPlatform.fuchsia:
177+
return GlowingOverscrollIndicator(
178+
axisDirection: details.direction,
179+
color: _kDefaultGlowColor,
180+
child: child,
181+
);
182+
}
201183
}
202184

203185
/// Specifies the type of velocity tracker to use in the descendant
@@ -243,6 +225,8 @@ class ScrollBehavior {
243225
/// [BouncingScrollPhysics] on iOS and [ClampingScrollPhysics] on
244226
/// Android.
245227
ScrollPhysics getScrollPhysics(BuildContext context) {
228+
// When modifying this function, consider modifying the implementation in
229+
// the Material and Cupertino subclasses as well.
246230
switch (getPlatform(context)) {
247231
case TargetPlatform.iOS:
248232
return _bouncingPhysics;
@@ -315,11 +299,6 @@ class _WrappedScrollBehavior implements ScrollBehavior {
315299
return child;
316300
}
317301

318-
@override
319-
Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) {
320-
return delegate.buildViewportChrome(context, child, axisDirection);
321-
}
322-
323302
@override
324303
ScrollBehavior copyWith({
325304
bool? scrollbars,

packages/flutter/test_fixes/cupertino.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,10 @@ void main() {
229229

230230
// Change made in https://github.com/flutter/flutter/pull/100381
231231
TextSelectionOverlay.fadeDuration;
232+
233+
// Changes made in https://github.com/flutter/flutter/pull/78588
234+
final ScrollBehavior scrollBehavior = ScrollBehavior();
235+
scrollBehavior.buildViewportChrome(context, child, axisDirection);
236+
final CupertinoScrollBehavior cupertinoScrollBehavior = CupertinoScrollBehavior();
237+
cupertinoScrollBehavior.buildViewportChrome(context, child, axisDirection);
232238
}

packages/flutter/test_fixes/cupertino.dart.expect

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,10 @@ void main() {
229229

230230
// Change made in https://github.com/flutter/flutter/pull/100381
231231
SelectionOverlay.fadeDuration;
232+
233+
// Changes made in https://github.com/flutter/flutter/pull/78588
234+
final ScrollBehavior scrollBehavior = ScrollBehavior();
235+
scrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
236+
final CupertinoScrollBehavior cupertinoScrollBehavior = CupertinoScrollBehavior();
237+
cupertinoScrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
232238
}

packages/flutter/test_fixes/material.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,12 @@ void main() {
695695
themeData = ThemeData.raw(bottomAppBarColor: Colors.green);
696696
themeData = ThemeData.copyWith(bottomAppBarColor: Colors.green);
697697

698+
// Changes made in https://github.com/flutter/flutter/pull/78588
699+
final ScrollBehavior scrollBehavior = ScrollBehavior();
700+
scrollBehavior.buildViewportChrome(context, child, axisDirection);
701+
final MaterialScrollBehavior materialScrollBehavior = MaterialScrollBehavior();
702+
materialScrollBehavior.buildViewportChrome(context, child, axisDirection);
703+
698704
// Changes made in https://github.com/flutter/flutter/pull/111706
699705
Scrollbar scrollbar = Scrollbar(showTrackOnHover: true);
700706
bool nowShowing = scrollbar.showTrackOnHover;

packages/flutter/test_fixes/material.dart.expect

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ void main() {
889889

890890
// Changes made in https://github.com/flutter/flutter/pull/110162
891891
ThemeData themeData = ThemeData();
892-
themeData = ThemeData(colorScheme: ColorScheme(error: Colors.red).copyWith(background: Colors.grey));
892+
themeData = ThemeData(colorScheme: ColorScheme(background: Colors.grey).copyWith(error: Colors.red));
893893
themeData = ThemeData.raw(colorScheme: ColorScheme(error: Colors.red).copyWith(background: Colors.grey));
894894
themeData = themeData.copyWith(colorScheme: ColorScheme(error: Colors.red).copyWith(background: Colors.grey));
895895

@@ -899,6 +899,12 @@ void main() {
899899
themeData = ThemeData.raw(bottomAppBarTheme: BottomAppBarTheme(color: Colors.green));
900900
themeData = ThemeData.copyWith(bottomAppBarTheme: BottomAppBarTheme(color: Colors.green));
901901

902+
// Changes made in https://github.com/flutter/flutter/pull/78588
903+
final ScrollBehavior scrollBehavior = ScrollBehavior();
904+
scrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
905+
final MaterialScrollBehavior materialScrollBehavior = MaterialScrollBehavior();
906+
materialScrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
907+
902908
// Changes made in https://github.com/flutter/flutter/pull/111706
903909
Scrollbar scrollbar = Scrollbar(trackVisibility: true);
904910
bool nowShowing = scrollbar.trackVisibility;

packages/flutter/test_fixes/widgets.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,8 @@ void main() {
184184

185185
// Change made in https://github.com/flutter/flutter/pull/100381
186186
TextSelectionOverlay.fadeDuration;
187+
188+
// Changes made in https://github.com/flutter/flutter/pull/78588
189+
final ScrollBehavior scrollBehavior = ScrollBehavior();
190+
scrollBehavior.buildViewportChrome(context, child, axisDirection);
187191
}

packages/flutter/test_fixes/widgets.dart.expect

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,8 @@ void main() {
184184

185185
// Change made in https://github.com/flutter/flutter/pull/100381
186186
SelectionOverlay.fadeDuration;
187+
188+
// Changes made in https://github.com/flutter/flutter/pull/78588
189+
final ScrollBehavior scrollBehavior = ScrollBehavior();
190+
scrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
187191
}

0 commit comments

Comments
 (0)