From 4bed76757db7a4eea74d77d5a63804ef52198f37 Mon Sep 17 00:00:00 2001 From: xubaolin Date: Sun, 8 May 2022 02:44:08 +0800 Subject: [PATCH] Fix a `_WrappedScrollBehavior.shouldNotify` bug (#103267) --- .../flutter/lib/src/widgets/scroll_configuration.dart | 2 +- packages/flutter/test/widgets/scroll_behavior_test.dart | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/widgets/scroll_configuration.dart b/packages/flutter/lib/src/widgets/scroll_configuration.dart index fdb1b613592c..46fc042f9d0d 100644 --- a/packages/flutter/lib/src/widgets/scroll_configuration.dart +++ b/packages/flutter/lib/src/widgets/scroll_configuration.dart @@ -348,7 +348,7 @@ class _WrappedScrollBehavior implements ScrollBehavior { || oldDelegate.overscroll != overscroll || oldDelegate.physics != physics || oldDelegate.platform != platform - || setEquals(oldDelegate.dragDevices, dragDevices) + || !setEquals(oldDelegate.dragDevices, dragDevices) || delegate.shouldNotify(oldDelegate.delegate); } diff --git a/packages/flutter/test/widgets/scroll_behavior_test.dart b/packages/flutter/test/widgets/scroll_behavior_test.dart index b45583b6fccf..a6cbd6428e0c 100644 --- a/packages/flutter/test/widgets/scroll_behavior_test.dart +++ b/packages/flutter/test/widgets/scroll_behavior_test.dart @@ -32,6 +32,14 @@ class TestScrollBehavior extends ScrollBehavior { } void main() { + // Regression test for https://github.com/flutter/flutter/issues/89681 + testWidgets('_WrappedScrollBehavior shouldNotify test', (WidgetTester tester) async { + final ScrollBehavior behavior1 = const ScrollBehavior().copyWith(); + final ScrollBehavior behavior2 = const ScrollBehavior().copyWith(); + + expect(behavior1.shouldNotify(behavior2), false); + }); + testWidgets('Inherited ScrollConfiguration changed', (WidgetTester tester) async { final GlobalKey key = GlobalKey(debugLabel: 'scrollable'); TestScrollBehavior? behavior;