Skip to content

Commit a75743e

Browse files
authored
Revert "Re-land reverse case for AppBar scrolled under" (#102580)
1 parent 6132b86 commit a75743e

File tree

5 files changed

+295
-479
lines changed

5 files changed

+295
-479
lines changed

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

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -767,33 +767,17 @@ class _AppBarState extends State<AppBar> {
767767
}
768768

769769
void _handleScrollNotification(ScrollNotification notification) {
770-
final bool oldScrolledUnder = _scrolledUnder;
771-
final ScrollMetrics metrics = notification.metrics;
772-
773-
if (notification.depth != 0) {
774-
_scrolledUnder = false;
775-
} else {
776-
switch (metrics.axisDirection) {
777-
case AxisDirection.up:
778-
// Scroll view is reversed
779-
_scrolledUnder = metrics.extentAfter > 0;
780-
break;
781-
case AxisDirection.down:
782-
_scrolledUnder = metrics.extentBefore > 0;
783-
break;
784-
case AxisDirection.right:
785-
case AxisDirection.left:
786-
// Scrolled under is only supported in the vertical axis.
787-
_scrolledUnder = false;
788-
break;
770+
if (notification is ScrollUpdateNotification) {
771+
final bool oldScrolledUnder = _scrolledUnder;
772+
_scrolledUnder = notification.depth == 0
773+
&& notification.metrics.extentBefore > 0
774+
&& notification.metrics.axis == Axis.vertical;
775+
if (_scrolledUnder != oldScrolledUnder) {
776+
setState(() {
777+
// React to a change in MaterialState.scrolledUnder
778+
});
789779
}
790780
}
791-
792-
if (_scrolledUnder != oldScrolledUnder) {
793-
setState(() {
794-
// React to a change in MaterialState.scrolledUnder
795-
});
796-
}
797781
}
798782

799783
Color _resolveColor(Set<MaterialState> states, Color? widgetColor, Color? themeColor, Color defaultColor) {

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

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:flutter/foundation.dart';
99
import 'framework.dart';
1010
import 'notification_listener.dart';
1111
import 'scroll_notification.dart';
12-
import 'scroll_position.dart';
1312

1413
/// A [ScrollNotification] listener for [ScrollNotificationObserver].
1514
///
@@ -152,26 +151,14 @@ class ScrollNotificationObserverState extends State<ScrollNotificationObserver>
152151

153152
@override
154153
Widget build(BuildContext context) {
155-
// A ScrollMetricsNotification allows listeners to be notified for an
156-
// initial state, as well as if the content dimensions change without
157-
// scrolling.
158-
return NotificationListener<ScrollMetricsNotification>(
159-
onNotification: (ScrollMetricsNotification notification) {
160-
_notifyListeners(_ConvertedScrollMetricsNotification(
161-
metrics: notification.metrics,
162-
context: notification.context,
163-
));
154+
return NotificationListener<ScrollNotification>(
155+
onNotification: (ScrollNotification notification) {
156+
_notifyListeners(notification);
164157
return false;
165158
},
166-
child: NotificationListener<ScrollNotification>(
167-
onNotification: (ScrollNotification notification) {
168-
_notifyListeners(notification);
169-
return false;
170-
},
171-
child: _ScrollNotificationObserverScope(
172-
scrollNotificationObserverState: this,
173-
child: widget.child,
174-
),
159+
child: _ScrollNotificationObserverScope(
160+
scrollNotificationObserverState: this,
161+
child: widget.child,
175162
),
176163
);
177164
}
@@ -183,10 +170,3 @@ class ScrollNotificationObserverState extends State<ScrollNotificationObserver>
183170
super.dispose();
184171
}
185172
}
186-
187-
class _ConvertedScrollMetricsNotification extends ScrollNotification {
188-
_ConvertedScrollMetricsNotification({
189-
required super.metrics,
190-
required super.context,
191-
});
192-
}

0 commit comments

Comments
 (0)