Commit 589cd0bb authored by Hans Muller's avatar Hans Muller

correct Block scrollableKey plumbing (#4048)

parent 199f24ad
...@@ -854,7 +854,7 @@ class Block extends StatelessWidget { ...@@ -854,7 +854,7 @@ class Block extends StatelessWidget {
if (padding != null) if (padding != null)
contents = new Padding(padding: padding, child: contents); contents = new Padding(padding: padding, child: contents);
return new ScrollableViewport( return new ScrollableViewport(
key: scrollableKey, scrollableKey: scrollableKey,
initialScrollOffset: initialScrollOffset, initialScrollOffset: initialScrollOffset,
scrollDirection: scrollDirection, scrollDirection: scrollDirection,
scrollAnchor: scrollAnchor, scrollAnchor: scrollAnchor,
......
...@@ -105,4 +105,18 @@ void main() { ...@@ -105,4 +105,18 @@ void main() {
expect(first, equals(1)); expect(first, equals(1));
expect(second, 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);
});
} }
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