我有一份名单。 类似:
ListView.builder(
key: _listViewKey,
controller: widget.scrollController,
shrinkWrap: true,
scrollDirection: Axis.vertical,
physics: const AlwaysScrollableScrollPhysics(),
itemCount: state.items,
itemBuilder: (context, index) {
...
此外,我还拥有使用滚动机打电话囚犯的最终方法。 将用户带至名单的底线,而不管其位置如何。 这里指的是:
void scrollToEnd() async {
await Future.delayed(const Duration(milliseconds: 300));
Future.doWhile(() {
if (widget.scrollController.positions.last.extentAfter == 0) {
return Future.value(false);
}
return widget.scrollController.animateTo(widget.scrollController.positions.last.maxScrollExtent, duration: Duration(milliseconds: 500), curve: Curves.linear).then((value) => true);
});
}
我发现,我叫Aimate 仅仅一次,雕刻就足够了,有时是滚动机走到底,因此制定了
However now when scrolling up the list a few items and evoking scrollToEnd() there seems to be a pretty severe overscroll and total whitespace is shown until eventually the last list items sinks back down into view. I have 2 questions:
- Why is widget.scrollController.positions.last.maxScrollExtent ever returning a higher value than the list actually has?
- How can I stop this overscroll from happening? My only goal is that scrollToEnd() gets the list to the end every time and that is doesnt look wonky when it does it.
Edit:所有清单项目的高度各异,因此,我需要一种解决办法,即围绕硬编码固定高度开展工作。