ScrollController will firstly scroll down and then scroll back for AnimatedList Flutter

Viewed 12

I try to combine ScrollController with AnimatedList, so atIndex position I will add a item in AnimatedList, and after item added ca. 1 sec, ScrollController should scroll to this index position. The weird thing is ScrollController indeed scroll down, but suddenly after that it will scroll back:

this is scrollController method:

  void _animateToIndex(int index) {
    Timer(
      Duration(milliseconds: 2100),
      () {
        _controller.animateTo(
          180 + index * _height,
          duration: Duration(seconds: 2),
          curve: Curves.ease,
        );
      },
    );
  }

the rest is normal widget for AnimatedList, if needed I will upload here, please tell me why scrollController will jump down and back, thank you!

0 Answers
Related