mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove deprecated ScrollBehavior.buildViewportChrome (#111715)
This commit is contained in:
parent
9e87a5b08a
commit
533229585d
@ -17,6 +17,39 @@
|
||||
|
||||
version: 1
|
||||
transforms:
|
||||
# Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
- title: "Migrate to 'buildOverscrollIndicator'"
|
||||
date: 2021-03-18
|
||||
element:
|
||||
uris: ['widgets.dart', 'material.dart', 'cupertino.dart']
|
||||
method: 'buildViewportChrome'
|
||||
inClass: 'ScrollBehavior'
|
||||
changes:
|
||||
- kind: 'rename'
|
||||
newName: 'buildOverscrollIndicator'
|
||||
|
||||
# Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
- title: "Migrate to 'buildOverscrollIndicator'"
|
||||
date: 2021-03-18
|
||||
element:
|
||||
uris: ['material.dart']
|
||||
method: 'buildViewportChrome'
|
||||
inClass: 'MaterialScrollBehavior'
|
||||
changes:
|
||||
- kind: 'rename'
|
||||
newName: 'buildOverscrollIndicator'
|
||||
|
||||
# Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
- title: "Migrate to 'buildOverscrollIndicator'"
|
||||
date: 2021-03-18
|
||||
element:
|
||||
uris: ['cupertino.dart']
|
||||
method: 'buildViewportChrome'
|
||||
inClass: 'CupertinoScrollBehavior'
|
||||
changes:
|
||||
- kind: 'rename'
|
||||
newName: 'buildOverscrollIndicator'
|
||||
|
||||
# Changes made in https://github.com/flutter/flutter/pull/111706
|
||||
- title: "Migrate to 'trackVisibility'"
|
||||
date: 2022-09-15
|
||||
|
||||
@ -480,6 +480,8 @@ class CupertinoScrollBehavior extends ScrollBehavior {
|
||||
|
||||
@override
|
||||
ScrollPhysics getScrollPhysics(BuildContext context) {
|
||||
// When modifying this function, consider modifying the implementation in
|
||||
// the base class ScrollBehavior as well.
|
||||
if (getPlatform(context) == TargetPlatform.macOS) {
|
||||
return const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast);
|
||||
}
|
||||
|
||||
@ -817,7 +817,7 @@ class MaterialScrollBehavior extends ScrollBehavior {
|
||||
@override
|
||||
Widget buildScrollbar(BuildContext context, Widget child, ScrollableDetails details) {
|
||||
// When modifying this function, consider modifying the implementation in
|
||||
// the base class as well.
|
||||
// the base class ScrollBehavior as well.
|
||||
switch (axisDirectionToAxis(details.direction)) {
|
||||
case Axis.horizontal:
|
||||
return child;
|
||||
@ -841,7 +841,7 @@ class MaterialScrollBehavior extends ScrollBehavior {
|
||||
@override
|
||||
Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) {
|
||||
// When modifying this function, consider modifying the implementation in
|
||||
// the base class as well.
|
||||
// the base class ScrollBehavior as well.
|
||||
late final AndroidOverscrollIndicator indicator;
|
||||
if (Theme.of(context).useMaterial3) {
|
||||
indicator = AndroidOverscrollIndicator.stretch;
|
||||
|
||||
@ -132,45 +132,6 @@ class ScrollBehavior {
|
||||
/// impossible to select text in scrollable containers and is not recommended.
|
||||
Set<PointerDeviceKind> get dragDevices => _kTouchLikeDeviceTypes;
|
||||
|
||||
/// Wraps the given widget, which scrolls in the given [AxisDirection].
|
||||
///
|
||||
/// For example, on Android, this method wraps the given widget with a
|
||||
/// [GlowingOverscrollIndicator] to provide visual feedback when the user
|
||||
/// overscrolls.
|
||||
///
|
||||
/// This method is deprecated. Use [ScrollBehavior.buildOverscrollIndicator]
|
||||
/// instead.
|
||||
@Deprecated(
|
||||
'Migrate to buildOverscrollIndicator. '
|
||||
'This feature was deprecated after v2.1.0-11.0.pre.',
|
||||
)
|
||||
Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) {
|
||||
switch (getPlatform(context)) {
|
||||
case TargetPlatform.iOS:
|
||||
case TargetPlatform.linux:
|
||||
case TargetPlatform.macOS:
|
||||
case TargetPlatform.windows:
|
||||
return child;
|
||||
case TargetPlatform.android:
|
||||
switch (androidOverscrollIndicator) {
|
||||
case AndroidOverscrollIndicator.stretch:
|
||||
return StretchingOverscrollIndicator(
|
||||
axisDirection: axisDirection,
|
||||
child: child,
|
||||
);
|
||||
case AndroidOverscrollIndicator.glow:
|
||||
continue glow;
|
||||
}
|
||||
glow:
|
||||
case TargetPlatform.fuchsia:
|
||||
return GlowingOverscrollIndicator(
|
||||
axisDirection: axisDirection,
|
||||
color: _kDefaultGlowColor,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Applies a [RawScrollbar] to the child widget on desktop platforms.
|
||||
Widget buildScrollbar(BuildContext context, Widget child, ScrollableDetails details) {
|
||||
// When modifying this function, consider modifying the implementation in
|
||||
@ -193,11 +154,32 @@ class ScrollBehavior {
|
||||
/// Applies a [GlowingOverscrollIndicator] to the child widget on
|
||||
/// [TargetPlatform.android] and [TargetPlatform.fuchsia].
|
||||
Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) {
|
||||
// TODO(Piinks): Move implementation from buildViewportChrome here after
|
||||
// deprecation period
|
||||
// When modifying this function, consider modifying the implementation in
|
||||
// the Material and Cupertino subclasses as well.
|
||||
return buildViewportChrome(context, child, details.direction);
|
||||
switch (getPlatform(context)) {
|
||||
case TargetPlatform.iOS:
|
||||
case TargetPlatform.linux:
|
||||
case TargetPlatform.macOS:
|
||||
case TargetPlatform.windows:
|
||||
return child;
|
||||
case TargetPlatform.android:
|
||||
switch (androidOverscrollIndicator) {
|
||||
case AndroidOverscrollIndicator.stretch:
|
||||
return StretchingOverscrollIndicator(
|
||||
axisDirection: details.direction,
|
||||
child: child,
|
||||
);
|
||||
case AndroidOverscrollIndicator.glow:
|
||||
continue glow;
|
||||
}
|
||||
glow:
|
||||
case TargetPlatform.fuchsia:
|
||||
return GlowingOverscrollIndicator(
|
||||
axisDirection: details.direction,
|
||||
color: _kDefaultGlowColor,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Specifies the type of velocity tracker to use in the descendant
|
||||
@ -243,6 +225,8 @@ class ScrollBehavior {
|
||||
/// [BouncingScrollPhysics] on iOS and [ClampingScrollPhysics] on
|
||||
/// Android.
|
||||
ScrollPhysics getScrollPhysics(BuildContext context) {
|
||||
// When modifying this function, consider modifying the implementation in
|
||||
// the Material and Cupertino subclasses as well.
|
||||
switch (getPlatform(context)) {
|
||||
case TargetPlatform.iOS:
|
||||
return _bouncingPhysics;
|
||||
@ -315,11 +299,6 @@ class _WrappedScrollBehavior implements ScrollBehavior {
|
||||
return child;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) {
|
||||
return delegate.buildViewportChrome(context, child, axisDirection);
|
||||
}
|
||||
|
||||
@override
|
||||
ScrollBehavior copyWith({
|
||||
bool? scrollbars,
|
||||
|
||||
@ -229,4 +229,10 @@ void main() {
|
||||
|
||||
// Change made in https://github.com/flutter/flutter/pull/100381
|
||||
TextSelectionOverlay.fadeDuration;
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
final ScrollBehavior scrollBehavior = ScrollBehavior();
|
||||
scrollBehavior.buildViewportChrome(context, child, axisDirection);
|
||||
final CupertinoScrollBehavior cupertinoScrollBehavior = CupertinoScrollBehavior();
|
||||
cupertinoScrollBehavior.buildViewportChrome(context, child, axisDirection);
|
||||
}
|
||||
|
||||
@ -229,4 +229,10 @@ void main() {
|
||||
|
||||
// Change made in https://github.com/flutter/flutter/pull/100381
|
||||
SelectionOverlay.fadeDuration;
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
final ScrollBehavior scrollBehavior = ScrollBehavior();
|
||||
scrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
|
||||
final CupertinoScrollBehavior cupertinoScrollBehavior = CupertinoScrollBehavior();
|
||||
cupertinoScrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
|
||||
}
|
||||
|
||||
@ -695,6 +695,12 @@ void main() {
|
||||
themeData = ThemeData.raw(bottomAppBarColor: Colors.green);
|
||||
themeData = ThemeData.copyWith(bottomAppBarColor: Colors.green);
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
final ScrollBehavior scrollBehavior = ScrollBehavior();
|
||||
scrollBehavior.buildViewportChrome(context, child, axisDirection);
|
||||
final MaterialScrollBehavior materialScrollBehavior = MaterialScrollBehavior();
|
||||
materialScrollBehavior.buildViewportChrome(context, child, axisDirection);
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/111706
|
||||
Scrollbar scrollbar = Scrollbar(showTrackOnHover: true);
|
||||
bool nowShowing = scrollbar.showTrackOnHover;
|
||||
|
||||
@ -889,7 +889,7 @@ void main() {
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/110162
|
||||
ThemeData themeData = ThemeData();
|
||||
themeData = ThemeData(colorScheme: ColorScheme(error: Colors.red).copyWith(background: Colors.grey));
|
||||
themeData = ThemeData(colorScheme: ColorScheme(background: Colors.grey).copyWith(error: Colors.red));
|
||||
themeData = ThemeData.raw(colorScheme: ColorScheme(error: Colors.red).copyWith(background: Colors.grey));
|
||||
themeData = themeData.copyWith(colorScheme: ColorScheme(error: Colors.red).copyWith(background: Colors.grey));
|
||||
|
||||
@ -899,6 +899,12 @@ void main() {
|
||||
themeData = ThemeData.raw(bottomAppBarTheme: BottomAppBarTheme(color: Colors.green));
|
||||
themeData = ThemeData.copyWith(bottomAppBarTheme: BottomAppBarTheme(color: Colors.green));
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
final ScrollBehavior scrollBehavior = ScrollBehavior();
|
||||
scrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
|
||||
final MaterialScrollBehavior materialScrollBehavior = MaterialScrollBehavior();
|
||||
materialScrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/111706
|
||||
Scrollbar scrollbar = Scrollbar(trackVisibility: true);
|
||||
bool nowShowing = scrollbar.trackVisibility;
|
||||
|
||||
@ -184,4 +184,8 @@ void main() {
|
||||
|
||||
// Change made in https://github.com/flutter/flutter/pull/100381
|
||||
TextSelectionOverlay.fadeDuration;
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
final ScrollBehavior scrollBehavior = ScrollBehavior();
|
||||
scrollBehavior.buildViewportChrome(context, child, axisDirection);
|
||||
}
|
||||
|
||||
@ -184,4 +184,8 @@ void main() {
|
||||
|
||||
// Change made in https://github.com/flutter/flutter/pull/100381
|
||||
SelectionOverlay.fadeDuration;
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
final ScrollBehavior scrollBehavior = ScrollBehavior();
|
||||
scrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user