Commit 6491cbf7 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Ensure PrimaryScrollController is returned when primary: true (#8440)

Also a small formatting fix.
parent af03ed1c
......@@ -30,7 +30,8 @@ abstract class ScrollView extends StatelessWidget {
assert(primary != null);
assert(controller == null || !primary,
'Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. '
'You cannot both set primary to true and pass an explicit controller.');
'You cannot both set primary to true and pass an explicit controller.'
);
}
final Axis scrollDirection;
......
......@@ -168,4 +168,34 @@ void main() {
expect(controller.offset, equals(550.0));
expect(log, isEmpty);
});
testWidgets('CustomScrollView sets PrimaryScrollController when primary', (WidgetTester tester) async {
ScrollController primaryScrollController = new ScrollController();
await tester.pumpWidget(new PrimaryScrollController(
controller: primaryScrollController,
child: new CustomScrollView(primary: true),
));
Scrollable scrollable = tester.widget(find.byType(Scrollable));
expect(scrollable.controller, primaryScrollController);
});
testWidgets('ListView sets PrimaryScrollController when primary', (WidgetTester tester) async {
ScrollController primaryScrollController = new ScrollController();
await tester.pumpWidget(new PrimaryScrollController(
controller: primaryScrollController,
child: new ListView(primary: true),
));
Scrollable scrollable = tester.widget(find.byType(Scrollable));
expect(scrollable.controller, primaryScrollController);
});
testWidgets('GridView sets PrimaryScrollController when primary', (WidgetTester tester) async {
ScrollController primaryScrollController = new ScrollController();
await tester.pumpWidget(new PrimaryScrollController(
controller: primaryScrollController,
child: new GridView.count(primary: true, crossAxisCount: 1),
));
Scrollable scrollable = tester.widget(find.byType(Scrollable));
expect(scrollable.controller, primaryScrollController);
});
}
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