0

I would like to know the index of the top visible widget in my ListViewBuilder

======================================

At this point I should get index 12

enter image description here

At this point I should get index 21

enter image description here

class XXX extends StatelessWidget {
  const XXX({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Test')),
      body: ListView.builder(
          reverse: true,
          itemCount: 50,
          itemBuilder: (context, index) {
            return Container(
              color: index.isEven ? Colors.amber : Colors.yellow,
              padding: EdgeInsets.all(12),
              child: Text("HELLO $index"),
            );
          }),
    );
  }
}
Ibrahim Ali
  • 2,083
  • 2
  • 15
  • 36
  • Does this answer your question? [How to know if a widget is visible within a viewport?](https://stackoverflow.com/questions/51069712/how-to-know-if-a-widget-is-visible-within-a-viewport) – OMi Shah Jul 31 '21 at 14:22
  • Is it same case? https://stackoverflow.com/a/67615525/11986450 – KuKu Jul 31 '21 at 16:28

0 Answers0