When I scroll the ListView.builder in the body of a NestedScrollView, it scrolls independently from the SliverToBoxAdapter and SliverList. This means when I scroll the listview.builder, only the colored part in the photo below moved.
How can I make it such that when I scroll the listview.builder, the whole screen moves together(even the SliverToBoxAdapter and SliverList scroll up together) and pagination can be done for the listview.builder when it reaches the end of the list?
Code for UI
Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool boxIsScrolled) {
return <Widget>[
SliverToBoxAdapter(child: SizedBox(height: 300)),
SliverList(
delegate: SliverChildListDelegate(
[
TabBar(
indicator: UnderlineTabIndicator(
borderSide: BorderSide(width: 1.5,color: Colors.white),
// insets: EdgeInsets.symmetric(horizontal:60.0)
),
tabs: <Widget>[
Icon(
CupertinoIcons.rectangle_grid_2x2,
),
Icon(
CupertinoIcons.doc_plaintext,
),
],
),
],
),
)
];
},
body:
TabBarView(
controller: _tabController,
children: [
ListView.builder(
controller: controller,
shrinkWrap: true,
itemCount: cardDetail.length,
itemBuilder: (BuildContext context, int index) {
return CardWidget(cardDetail[index], index);
}),
ListView.builder(
controller: differentController,
shrinkWrap: true,
itemCount: differentCardDetail.length,
itemBuilder: (BuildContext context, int index) {
return CardWidget(differentCardDetail[index], index);
}),
],
),
),
);
Code for pagination
_controller = ScrollController();
_controller.addListener(_scrollListener);
_scrollListener()async {
if (_controller.offset >= _controller.position.maxScrollExtent &&
!_controller.position.outOfRange) {
loadMoreData();
}
}