animateToBack method

Future<void> animateToBack()

Animates listController to the _itemToReturnTo.

Implementation

Future<void> animateToBack() async {
  if (_itemToReturnTo != null) {
    canGoBack.value = false;
    try {
      _ignorePositionChanges = true;

      if (listController.hasClients) {
        await listController.sliverController.animateToIndex(
          _itemToReturnTo!.index,
          offsetBasedOnBottom: true,
          offset: _itemToReturnTo!.offset,
          duration: 200.milliseconds,
          curve: Curves.ease,
        );
      } else {
        initIndex = _itemToReturnTo!.index;
      }
    } finally {
      _ignorePositionChanges = false;
      _listControllerListener();
    }
  }
}