I wish to create the following: when reaching the top or bottom of the inner Listview, I want to continue scrolling in the top Listview. See GIF:
An option would be to set the physics of the inner Listview to NeverScrollablePhysics when the bottom is reached (using a Listener to the controller) but then if you would want to scroll up again this wouldn't work.
See below for my code, thanks in advance!
class TestAppHomePage extends StatefulWidget {
@override
TestAppHomePageState createState() => new TestAppHomePageState();
}
class TestAppHomePageState extends State<TestAppHomePage> {
ScrollController _scrollController = ScrollController();
@override
void initState() {
print('set up');
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: Container(
color: Colors.green,
child: ListView(
primary: false,
// controller: _scrollController,
children: <Widget>[topWidget(), topWidget(), topWidget(), topWidget()],
),
),
);
}
Widget topWidget() {
return Card(
color: Colors.purple,
margin: EdgeInsets.all(16),
child: Container(
height: 400,
child: Column(
children: <Widget>[
Container(height: 100, color: Colors.white),
Expanded(
child: ListView(
controller: _scrollController,
children: List.generate(
40,
(index) {
return someText(index);
},
).toList()))
],
),
));
}
Widget someText(int i) {
return Text('text no $i');
}
}
shrinkWrap: true
, It will breaking the reuse mechanism in ListView. Which will very slowly if the item count is huge. – Favourable