Commit 39d9bcda authored by Hans Muller's avatar Hans Muller Committed by GitHub

ListView.Builder() handles appends when scrolled to the end (#9533)

parent df45aac1
......@@ -209,6 +209,10 @@ abstract class RenderSliverFixedExtentBoxAdaptor extends RenderSliverMultiBoxAda
|| constraints.scrollOffset > 0.0,
);
// We may have started the layout while scrolled to the end, which would not
// expose a new child.
if (estimatedMaxScrollOffset == trailingScrollOffset)
childManager.setDidUnderflow(true);
childManager.didFinishLayout();
}
}
......
......@@ -589,6 +589,10 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor {
hasVisualOverflow: true,
);
// We may have started the layout while scrolled to the end, which
// would not expose a new child.
if (estimatedTotalExtent == trailingScrollOffset)
childManager.setDidUnderflow(true);
childManager.didFinishLayout();
}
}
......@@ -243,6 +243,10 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor {
hasVisualOverflow: endScrollOffset > targetEndScrollOffset || constraints.scrollOffset > 0.0,
);
// We may have started the layout while scrolled to the end, which would not
// expose a new child.
if (estimatedMaxScrollOffset == endScrollOffset)
childManager.setDidUnderflow(true);
childManager.didFinishLayout();
}
}
......@@ -124,9 +124,6 @@ void main() {
expect(find.text('300'), findsOneWidget);
expect(find.text('400'), findsOneWidget);
expect(find.text('100'), findsNothing);
final RenderSliverList list = tester.renderObject(find.byType(SliverList));
expect(list.geometry.scrollExtent, equals(700.0));
});
testWidgets('Overflowing ListView should become scrollable', (WidgetTester tester) async {
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
void main() {
testWidgets('ListView.builder() fixed itemExtent, scroll to end, append, scroll', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/9506
Widget buildFrame(int itemCount) {
return new ListView.builder(
itemExtent: 200.0,
itemCount: itemCount,
itemBuilder: (BuildContext context, int index) => new Text('item $index'),
);
}
await tester.pumpWidget(buildFrame(3));
expect(find.text('item 0'), findsOneWidget);
expect(find.text('item 1'), findsOneWidget);
expect(find.text('item 2'), findsOneWidget);
await tester.pumpWidget(buildFrame(4));
expect(find.text('item 3'), findsNothing);
final TestGesture gesture = await tester.startGesture(const Offset(0.0, 300.0));
await gesture.moveBy(const Offset(0.0, -200.0));
await tester.pumpAndSettle();
expect(find.text('item 3'), findsOneWidget);
});
testWidgets('ListView.builder() fixed itemExtent, scroll to end, append, scroll', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/9506
Widget buildFrame(int itemCount) {
return new ListView.builder(
itemCount: itemCount,
itemBuilder: (BuildContext context, int index) {
return new SizedBox(
height: 200.0,
child: new Text('item $index'),
);
},
);
}
await tester.pumpWidget(buildFrame(3));
expect(find.text('item 0'), findsOneWidget);
expect(find.text('item 1'), findsOneWidget);
expect(find.text('item 2'), findsOneWidget);
await tester.pumpWidget(buildFrame(4));
final TestGesture gesture = await tester.startGesture(const Offset(0.0, 300.0));
await gesture.moveBy(const Offset(0.0, -200.0));
await tester.pumpAndSettle();
expect(find.text('item 3'), findsOneWidget);
});
}
......@@ -68,4 +68,31 @@ void main() {
expect(find.text('3'), findsNothing);
expect(find.text('4'), findsNothing);
});
testWidgets('GridView.count() fixed itemExtent, scroll to end, append, scroll', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/9506
Widget buildFrame(int itemCount) {
return new GridView.count(
crossAxisCount: itemCount,
children: new List<Widget>.generate(itemCount, (int index) {
return new SizedBox(
height: 200.0,
child: new Text('item $index'),
);
}),
);
}
await tester.pumpWidget(buildFrame(3));
expect(find.text('item 0'), findsOneWidget);
expect(find.text('item 1'), findsOneWidget);
expect(find.text('item 2'), findsOneWidget);
await tester.pumpWidget(buildFrame(4));
final TestGesture gesture = await tester.startGesture(const Offset(0.0, 300.0));
await gesture.moveBy(const Offset(0.0, -200.0));
await tester.pumpAndSettle();
expect(find.text('item 3'), findsOneWidget);
});
}
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