Fix sliver padding assertion failure that sometimes happens during startup because the app is temporarily built with zero size

This commit is contained in:
Collin Jackson
2017-05-18 17:31:57 -07:00
parent 00214fa7bd
commit 973304d5fb
2 changed files with 19 additions and 1 deletions

View File

@@ -146,7 +146,7 @@ class RenderSliverPadding extends RenderSliver with RenderObjectWithChildMixin<R
scrollOffset: math.max(0.0, constraints.scrollOffset - beforePadding),
overlap: 0.0,
remainingPaintExtent: constraints.remainingPaintExtent - calculatePaintOffset(constraints, from: 0.0, to: beforePadding),
crossAxisExtent: constraints.crossAxisExtent - crossAxisPadding,
crossAxisExtent: math.max(0.0, constraints.crossAxisExtent - crossAxisPadding),
),
parentUsesSize: true,
);

View File

@@ -156,6 +156,24 @@ void main() {
expect(find.text('5'), findsNothing);
});
testWidgets('ListView can build out of overflow padding', (WidgetTester tester) async {
await tester.pumpWidget(
new Center(
child: new SizedBox(
width: 0.0,
height: 0.0,
child: new ListView(
padding: const EdgeInsets.all(8.0),
children: <Widget>[
const Text('padded'),
],
),
),
),
);
expect(find.text('padded'), findsOneWidget);
});
testWidgets('ListView with itemExtent in unbounded context', (WidgetTester tester) async {
await tester.pumpWidget(
new SingleChildScrollView(