Commit 40151689 authored by Adam Barth's avatar Adam Barth

ScrollableList was applying padding twice

We need to subtract the padding instead of adding it.
parent 4e4887a9
......@@ -193,8 +193,8 @@ class _VirtualListViewportElement extends VirtualViewportElement<_VirtualListVie
_startOffsetBase = 0.0;
_startOffsetLimit = double.INFINITY;
} else {
int startItem = math.max(0, (widget.startOffset + leadingPadding) ~/ itemExtent);
int limitItem = math.max(0, ((widget.startOffset + leadingPadding + containerExtent) / itemExtent).ceil());
int startItem = math.max(0, (widget.startOffset - leadingPadding) ~/ itemExtent);
int limitItem = math.max(0, ((widget.startOffset - leadingPadding + containerExtent) / itemExtent).ceil());
if (!widget.itemsWrap && length != null) {
startItem = math.min(length, startItem);
......
......@@ -65,4 +65,45 @@ void main() {
expect(tester.findText('5'), isNull);
});
});
test('Drag vertically', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(
new ScrollableList(
itemExtent: 290.0,
padding: new EdgeDims.only(top: 250.0),
scrollDirection: Axis.vertical,
children: items.map((int item) {
return new Container(
child: new Text('$item')
);
})
)
);
tester.pump();
// screen is 600px high, and has the following items:
// 250..540 = 0
// 540..830 = 1
expect(tester.findText('0'), isNotNull);
expect(tester.findText('1'), isNotNull);
expect(tester.findText('2'), isNull);
expect(tester.findText('3'), isNull);
expect(tester.findText('4'), isNull);
expect(tester.findText('5'), isNull);
tester.scroll(tester.findText('0'), const Offset(0.0, -300.0));
tester.pump();
// screen is 600px high, and has the following items:
// -50..240 = 0
// 240..530 = 1
// 530..820 = 2
expect(tester.findText('0'), isNotNull);
expect(tester.findText('1'), isNotNull);
expect(tester.findText('2'), isNotNull);
expect(tester.findText('3'), isNull);
expect(tester.findText('4'), isNull);
expect(tester.findText('5'), isNull);
});
});
}
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