computeItemBox method

Rect? computeItemBox(
  1. int index, [
  2. bool absolute = false
])

Calculates the box (in pixels) of the item indicated by the index provided.

The index of the item refers to the index of the underlying list.

If absolute is false the offset is relative to the upper edge of the sliver, otherwise the offset is relative to the upper edge of the topmost sliver.

For one, you might pass the result to the ScrollController.jumpTo or ScrollController.animateTo methods of a ScrollController to scroll to the desired item.

The method returns null if the box cannot be calculated. This happens when the item isn't yet diplayed (because animations are still in progress) or when the state of the list view has been changed via notifications but these changes are not yet taken into account.

Be careful! This method calculates the item box starting from items currently built in the viewport, therefore, if the desired item is very far from them, the method could take a long time to return the result since it must measure all the intermediate items that are among those of the viewport and the desired one.

Implementation

Rect? computeItemBox(int index, [bool absolute = false]) {
  assert(_debugAssertBinded());
  return _interface!.computeItemBox(index, absolute);
}