correct Block scrollableKey plumbing (#4048)

This commit is contained in:
Hans Muller 2016-05-19 12:44:16 -07:00
parent 199f24ad3d
commit 589cd0bb67
2 changed files with 15 additions and 1 deletions

View File

@ -854,7 +854,7 @@ class Block extends StatelessWidget {
if (padding != null)
contents = new Padding(padding: padding, child: contents);
return new ScrollableViewport(
key: scrollableKey,
scrollableKey: scrollableKey,
initialScrollOffset: initialScrollOffset,
scrollDirection: scrollDirection,
scrollAnchor: scrollAnchor,

View File

@ -105,4 +105,18 @@ void main() {
expect(first, equals(1));
expect(second, equals(1));
});
testWidgets('Block scrollableKey', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/4046
// The Block's scrollableKey needs to become its Scrollable descendant's key.
final GlobalKey<ScrollableState<Scrollable>> key = new GlobalKey<ScrollableState<Scrollable>>();
Widget buildBlock() {
return new Block(
scrollableKey: key,
children: <Widget>[new Text("A"), new Text("B"), new Text("C")]
);
}
await tester.pumpWidget(buildBlock());
expect(key.currentState.scrollOffset, 0.0);
});
}