ScrollableList was applying padding twice
We need to subtract the padding instead of adding it.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user