clickIndexBar method

void clickIndexBar(
  1. int index
)

点击索引,列表滑动

Implementation

void clickIndexBar(int index) {
  double position = 0;
  int length = 0;
  // 计算位置
  for (int i = 0; i < _mList.length; i++) {
    if (_mList[index].letter == _mList[i].letter) {
      if (i == 0) {
        position = 0;
      } else {
        position = i * widget.itemHeadHeight! + length * widget.itemHeight!;
      }
    }
    length += _mList[i].data!.length;
  }
  _scrollController.animateTo(position,
      duration: Duration(milliseconds: 10), curve: Curves.linear);
}