Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter listview builder Scroll controller listener not firing inside list view?

I have a listview builder widget inside another list view. Inner listview listener is not firing when scrolling position reaches to its end.

initState() {
   super.initState();

  _scrollController.addListener(() {
  if (_scrollController.position.maxScrollExtent ==
      _scrollController.position.pixels) {function();}
}

Container(
 child: Listview(
  children: <Widget>[
    Container(),
    ListView.builder(
      controller: _scrollController,
      physics: NeverScrollableScrollPhysics(),
      shrinkWrap: true,
      itemCount: list.length,
      itemBuilder: (BuildContext context, int index) {
         return Container();
      },
   ),
  ]
 )
)
like image 729
afsal.an Avatar asked Mar 02 '23 07:03

afsal.an


1 Answers

You might have SingleChildScrollView attached before any widget :

so attach _scrollController to singleChildScrollView not listview

body: SingleChildScrollView(
        controller: _scrollController,
        child: Column(
          children: [
            _chips(),
            SizedBox(
              height: 10,
            ),
            _slider(),
            _showGrid(),
          ],
        ),
      ),
like image 81
Vaibhav Pallod Avatar answered Mar 05 '23 04:03

Vaibhav Pallod