quire-io / scroll-to-index

scroll to index with fixed/variable row height inside Flutter scrollable widget
MIT License
518 stars 105 forks source link

scroll_to_index is not working nested scroll view (ListView.buielder() insider inside Listview) #49

Closed imSanjaySoni closed 3 years ago

imSanjaySoni commented 3 years ago

Can you please help, How can Use scroll_to_index list inside a list?


 @override
 Widget build(BuildContext context) {
   return Scaffold(
     appBar: AppBar(
       // Here we take the value from the MyHomePage object that was created by
       // the App.build method, and use it to set our appbar title.
       title: Text(widget.title),
     ),
     body: ListView(
       shrinkWrap: true,
       children: [
         Container(
           color: Colors.amber,
           height: 40,
         ),
         ListView.builder(
             shrinkWrap: true,
             controller: controller,
             itemCount: 100,
             physics: NeverScrollableScrollPhysics(),
             itemBuilder: (c, i) => AutoScrollTag(
                   key: ValueKey(i),
                   controller: controller,
                   index: i,
                   child: Container(
                     height: 200,
                     color: Colors.red,
                     margin: EdgeInsets.all(16),
                   ),
                 )),
       ],
     ),
     floatingActionButton: FloatingActionButton(
       onPressed: _incrementCounter,
       tooltip: 'Increment',
       child: Icon(Icons.add),
     ), // This trailing comma makes auto-formatting nicer for build methods.
   );
 }
}
jerrywell commented 3 years ago

just merged the container and list view builder into custom scroll view, please see the migration example: the section of Transitioning to CustomScrollView in https://api.flutter.dev/flutter/widgets/ListView-class.html.

SlickSlime commented 3 years ago

@jerrywell Can you please explain the reason for this issue? I am facing a similar issue where .highlight() is working as expected but .scrollToIndex() is not scrolling the list item even after transitioning to CustomScrollView.

jerrywell commented 3 years ago

the single level children should work fine in this package. you can post the issue if it doesn't work.