From 30fed3a05dd479e4cb1ff7998922f5af0cc7b0e2 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Wed, 15 May 2019 07:15:34 -0700 Subject: [PATCH] Material should not prevent ScrollNotifications from bubbling upwards (#32726) --- .../flutter/lib/src/material/material.dart | 2 +- .../widgets/scroll_notification_test.dart | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index 82bcaa421c..5442676552 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -339,7 +339,7 @@ class _MaterialState extends State with TickerProviderStateMixin { onNotification: (LayoutChangedNotification notification) { final _RenderInkFeatures renderer = _inkFeatureRenderer.currentContext.findRenderObject(); renderer._didChangeLayout(); - return true; + return false; }, child: _InkFeatures( key: _inkFeatureRenderer, diff --git a/packages/flutter/test/widgets/scroll_notification_test.dart b/packages/flutter/test/widgets/scroll_notification_test.dart index f0e9b49879..0fe942d385 100644 --- a/packages/flutter/test/widgets/scroll_notification_test.dart +++ b/packages/flutter/test/widgets/scroll_notification_test.dart @@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; void main() { @@ -101,4 +102,53 @@ void main() { expect(depth0Values, equals([0, 0, 0, 0, 0])); expect(depth1Values, equals([1, 1, 1, 1, 1])); }); + + testWidgets('ScrollNotifications bubble past Scaffold Material', (WidgetTester tester) async { + final List notificationTypes = []; + + await tester.pumpWidget( + MaterialApp( + home: NotificationListener( + onNotification: (ScrollNotification value) { + notificationTypes.add(value.runtimeType); + return false; + }, + child: Scaffold( + body: SizedBox.expand( + child: SingleChildScrollView( + dragStartBehavior: DragStartBehavior.down, + child: SizedBox( + height: 1200.0, + child: Container( + padding: const EdgeInsets.all(50.0), + child: const SingleChildScrollView( + child: SizedBox(height: 1200.0), + dragStartBehavior: DragStartBehavior.down, + ), + ), + ), + ), + ), + ), + ), + ), + ); + + final TestGesture gesture = await tester.startGesture(const Offset(100.0, 100.0)); + await tester.pump(const Duration(seconds: 1)); + await gesture.moveBy(const Offset(-10.0, -40.0)); + await tester.pump(const Duration(seconds: 1)); + await gesture.up(); + await tester.pump(const Duration(seconds: 1)); + + final List types = [ + ScrollStartNotification, + UserScrollNotification, + ScrollUpdateNotification, + ScrollEndNotification, + UserScrollNotification, + ]; + expect(notificationTypes, equals(types)); + }); + }