向 ListView 添加新项目(例如 ListTile)时,是否可以将新添加的项目滚动到 View 中?新项目可能不在列表底部(例如,它按字母顺序排序)。
最佳答案
您可以使用 ScrollController
滚动浏览 ListView
.
final scrollController = ScrollController();
// ...
ListView(controller: scrollController // ...
);
// ...
scrollController.animateTo(height, duration: Duration(milliseconds: 678),
curve: Curves.ease);
您必须自己确定高度。这可以使用您的项目的索引和一般项目高度来完成。
关于flutter - 如何滚动 ListView 中的项目使其可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47367917/