Unverified Commit a75743e8 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Revert "Re-land reverse case for AppBar scrolled under" (#102580)

parent 6132b86d
...@@ -767,33 +767,17 @@ class _AppBarState extends State<AppBar> { ...@@ -767,33 +767,17 @@ class _AppBarState extends State<AppBar> {
} }
void _handleScrollNotification(ScrollNotification notification) { void _handleScrollNotification(ScrollNotification notification) {
final bool oldScrolledUnder = _scrolledUnder; if (notification is ScrollUpdateNotification) {
final ScrollMetrics metrics = notification.metrics; final bool oldScrolledUnder = _scrolledUnder;
_scrolledUnder = notification.depth == 0
if (notification.depth != 0) { && notification.metrics.extentBefore > 0
_scrolledUnder = false; && notification.metrics.axis == Axis.vertical;
} else { if (_scrolledUnder != oldScrolledUnder) {
switch (metrics.axisDirection) { setState(() {
case AxisDirection.up: // React to a change in MaterialState.scrolledUnder
// Scroll view is reversed });
_scrolledUnder = metrics.extentAfter > 0;
break;
case AxisDirection.down:
_scrolledUnder = metrics.extentBefore > 0;
break;
case AxisDirection.right:
case AxisDirection.left:
// Scrolled under is only supported in the vertical axis.
_scrolledUnder = false;
break;
} }
} }
if (_scrolledUnder != oldScrolledUnder) {
setState(() {
// React to a change in MaterialState.scrolledUnder
});
}
} }
Color _resolveColor(Set<MaterialState> states, Color? widgetColor, Color? themeColor, Color defaultColor) { Color _resolveColor(Set<MaterialState> states, Color? widgetColor, Color? themeColor, Color defaultColor) {
......
...@@ -9,7 +9,6 @@ import 'package:flutter/foundation.dart'; ...@@ -9,7 +9,6 @@ import 'package:flutter/foundation.dart';
import 'framework.dart'; import 'framework.dart';
import 'notification_listener.dart'; import 'notification_listener.dart';
import 'scroll_notification.dart'; import 'scroll_notification.dart';
import 'scroll_position.dart';
/// A [ScrollNotification] listener for [ScrollNotificationObserver]. /// A [ScrollNotification] listener for [ScrollNotificationObserver].
/// ///
...@@ -152,26 +151,14 @@ class ScrollNotificationObserverState extends State<ScrollNotificationObserver> ...@@ -152,26 +151,14 @@ class ScrollNotificationObserverState extends State<ScrollNotificationObserver>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// A ScrollMetricsNotification allows listeners to be notified for an return NotificationListener<ScrollNotification>(
// initial state, as well as if the content dimensions change without onNotification: (ScrollNotification notification) {
// scrolling. _notifyListeners(notification);
return NotificationListener<ScrollMetricsNotification>(
onNotification: (ScrollMetricsNotification notification) {
_notifyListeners(_ConvertedScrollMetricsNotification(
metrics: notification.metrics,
context: notification.context,
));
return false; return false;
}, },
child: NotificationListener<ScrollNotification>( child: _ScrollNotificationObserverScope(
onNotification: (ScrollNotification notification) { scrollNotificationObserverState: this,
_notifyListeners(notification); child: widget.child,
return false;
},
child: _ScrollNotificationObserverScope(
scrollNotificationObserverState: this,
child: widget.child,
),
), ),
); );
} }
...@@ -183,10 +170,3 @@ class ScrollNotificationObserverState extends State<ScrollNotificationObserver> ...@@ -183,10 +170,3 @@ class ScrollNotificationObserverState extends State<ScrollNotificationObserver>
super.dispose(); super.dispose();
} }
} }
class _ConvertedScrollMetricsNotification extends ScrollNotification {
_ConvertedScrollMetricsNotification({
required super.metrics,
required super.context,
});
}
...@@ -349,7 +349,6 @@ void main() { ...@@ -349,7 +349,6 @@ void main() {
' Material\n' ' Material\n'
' _ScrollNotificationObserverScope\n' ' _ScrollNotificationObserverScope\n'
' NotificationListener<ScrollNotification>\n' ' NotificationListener<ScrollNotification>\n'
' NotificationListener<ScrollMetricsNotification>\n'
' ScrollNotificationObserver\n' ' ScrollNotificationObserver\n'
' _ScaffoldScope\n' ' _ScaffoldScope\n'
' Scaffold-[LabeledGlobalKey<ScaffoldState>#00000]\n' ' Scaffold-[LabeledGlobalKey<ScaffoldState>#00000]\n'
......
...@@ -2339,7 +2339,6 @@ void main() { ...@@ -2339,7 +2339,6 @@ void main() {
' Material\n' ' Material\n'
' _ScrollNotificationObserverScope\n' ' _ScrollNotificationObserverScope\n'
' NotificationListener<ScrollNotification>\n' ' NotificationListener<ScrollNotification>\n'
' NotificationListener<ScrollMetricsNotification>\n'
' ScrollNotificationObserver\n' ' ScrollNotificationObserver\n'
' _ScaffoldScope\n' ' _ScaffoldScope\n'
' Scaffold\n' ' Scaffold\n'
......
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