How to get the height of the whole list.builder in flutter


I need to get the whole list.builder height including the part that is out of the screen view
The List children vary in height

i used the GlobalKey method but it is giving me only the height of the list shown in the screen

I found this solution and it’s working and give me the full list.builder height after scrolling event
but when adding more children to the list.builder by changing the state
this code doesn’t work anymore

scrollController.addListener(() {
double? fullListViewHeight;

  double fullListHeightHelper = listKey.currentContext!.size!.height +
  fullListView ??= fullListHeightHelper;

>Solution :

listview.builder only build the item that shown to user, in order to get the height with GlobalKey method, you can use listView which build all item at the same time. If you don’t know how pass your list to listView , see this example:

List yourList = [...];
  List<Widget> _children => YourListItem()).toList();

  return ListView(
     children: _children,

Leave a ReplyCancel reply