diff --git a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart index 894e6754e90..cdb718ef1a3 100644 --- a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart +++ b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart @@ -198,7 +198,6 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc if (pixels != value) { final double oldPixels = pixels; forcePixels(value); - notifyListeners(); didStartScroll(); didUpdateScrollPositionBy(pixels - oldPixels); didEndScroll(); @@ -213,7 +212,6 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc if (pixels != value) { final double oldPixels = pixels; forcePixels(value); - notifyListeners(); didStartScroll(); didUpdateScrollPositionBy(pixels - oldPixels); didEndScroll(); diff --git a/packages/flutter/test/widgets/scroll_position_test.dart b/packages/flutter/test/widgets/scroll_position_test.dart index 7771ffec642..3655bf55a4e 100644 --- a/packages/flutter/test/widgets/scroll_position_test.dart +++ b/packages/flutter/test/widgets/scroll_position_test.dart @@ -141,6 +141,25 @@ Future performTest(WidgetTester tester, bool maintainState) async { } void main() { + testWidgets('ScrollPosition jumpTo() doesn\'t call notifyListeners twice', (WidgetTester tester) async { + int count = 0; + await tester.pumpWidget(MaterialApp( + home: ListView.builder( + itemBuilder: (BuildContext context, int index) { + return Text('$index', textDirection: TextDirection.ltr); + }, + ), + )); + + final ScrollPosition position = tester.state(find.byType(Scrollable)).position; + position.addListener(() { + count++; + }); + position.jumpTo(100); + + expect(count, 1); + }); + testWidgets('whether we remember our scroll position', (WidgetTester tester) async { await performTest(tester, true); await performTest(tester, false);