Unverified Commit fcd90c0a authored by nujz's avatar nujz Committed by GitHub

ScrollPosition.jumpTo call notifyListeners twice (#53425)

parent 560c7228
......@@ -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();
......
......@@ -141,6 +141,25 @@ Future<void> 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<ScrollableState>(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);
......
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