颤振不回滚

时间:2020-11-04 17:05:09

标签: android ios flutter listview dart

CODE

 Widget getMainListViewUI() {
    return FutureBuilder<bool>(
      future: getData(),
      builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
        if (!snapshot.hasData) {
          return SizedBox();
        } else {
          return ListView.builder(
            controller: scrollController,
            padding: EdgeInsets.only(
              top: AppBar().preferredSize.height +
                  MediaQuery.of(context).padding.top +
                  24,
              bottom: 62 + MediaQuery.of(context).padding.bottom,
            ),
            itemCount: data.length,
            scrollDirection: Axis.vertical,
            itemBuilder: (BuildContext context, int index) {
              widget.animationController.forward();
              return AnimatedBuilder(
                animation: widget.animationController,
                builder: (BuildContext context, Widget child) {
                  return TutorialsListWidget(
                      animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
                              parent: widget.animationController,
                              curve: Interval((1 / data.length) * index, 1.0,
                                  curve: Curves.fastOutSlowIn))),
                      animationController: widget.animationController,
                      Count: data.length,
                      Heading: data[index]['Heading'],
                      Index: index);
                },
              );
            },
          );
        }
      },
    );
  }

这是我的Listview代码,在向下滚动时效果很好。我可以平滑滚动到屏幕底部,但没有问题,但是如果我尝试向后滚动(向上滚动),它会强制不滚动而转到顶部。

示例: 向下滚动:1-2-3-4-5-6-7-8-9-10 向上滚动:10-9-2-1

它强制地移到Listview的顶部。我在这里想念东西吗?

1 个答案:

答案 0 :(得分:0)

有时调试构建速度很慢。 尝试使用发布版本。