Unverified Commit 337290e6 authored by xubaolin's avatar xubaolin Committed by GitHub

fix a RenderSliverFixedExtentBoxAdaptor Exception (#72922)

parent 38fe7e2b
......@@ -195,7 +195,7 @@ abstract class RenderSliverFixedExtentBoxAdaptor extends RenderSliverMultiBoxAda
if (firstChild != null) {
final int leadingGarbage = _calculateLeadingGarbage(firstIndex);
final int trailingGarbage = _calculateTrailingGarbage(targetLastIndex!);
final int trailingGarbage = targetLastIndex != null ? _calculateTrailingGarbage(targetLastIndex) : 0;
collectGarbage(leadingGarbage, trailingGarbage);
} else {
collectGarbage(0, 0);
......
......@@ -352,6 +352,29 @@ void main() {
await tester.pumpWidget(buildFrame(itemCount: 4));
expect(scrollable().semanticChildCount, 4);
});
// Regression test for https://github.com/flutter/flutter/issues/72292
testWidgets('ListView.builder and SingleChildScrollView can work well together', (WidgetTester tester) async {
Widget builder(int itemCount) {
return Directionality(
textDirection: TextDirection.ltr,
child: SingleChildScrollView(
child: ListView.builder(
shrinkWrap: true,
itemExtent: 35,
itemCount: itemCount,
itemBuilder: (BuildContext context, int index) {
return const Text('I love Flutter.');
},
),
),
);
}
await tester.pumpWidget(builder(1));
// Trigger relayout and garbage collect.
await tester.pumpWidget(builder(2));
});
}
void check({ List<int> visible = const <int>[], List<int> hidden = const <int>[] }) {
......
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