mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
ScrollPosition.jumpTo call notifyListeners twice (#53425)
This commit is contained in:
parent
560c72287b
commit
fcd90c0a51
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user