Ensure PrimaryScrollController is returned when primary: true (#8440)
Also a small formatting fix.
This commit is contained in:
parent
af03ed1c79
commit
6491cbf7a3
@ -30,7 +30,8 @@ abstract class ScrollView extends StatelessWidget {
|
|||||||
assert(primary != null);
|
assert(primary != null);
|
||||||
assert(controller == null || !primary,
|
assert(controller == null || !primary,
|
||||||
'Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. '
|
'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;
|
final Axis scrollDirection;
|
||||||
|
@ -168,4 +168,34 @@ void main() {
|
|||||||
expect(controller.offset, equals(550.0));
|
expect(controller.offset, equals(550.0));
|
||||||
expect(log, isEmpty);
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user