In this article, you will learn how to programatically scrolling to the end of the ListView using the ListView widget in Flutter. You will get to know about ListView widget and how to use them.
How to Animate a Widget Across Screens in Flutter.pptx
How to Programmatically Scrolling to the End of a ListView in Flutter.pptx
1.
2. How to Programmatically Scrolling to the End of a
ListView in Flutter?
A ListView is a scrollable collection of widgets organized linearly in
Flutter. Additionally, it is the scrolling widget that is used the most. So,
we will examine what the ListView widget in Flutter is in this article.
The ListView Widget in Flutter fulfils the necessary tasks by placing the
elements inside it in the correct order according to the Flutter
developer requirements.
3. ListViews Widgets come in the following four types:
Learn more about the listview widget and its type for more details.
In our code, we sometimes need to scroll the list view to the Top or
bottom (programmatically). So, in this article, We will learn how to
scroll down to the bottom of a ListView in Flutter.
ListView()
ListView.builder()
ListView.separated()
ListView.custom()
4. To manage our ListView, we will want a ScrollController.
ScrollController _scrollController = ScrollController();
To jump listview from top to bottom, you can use the below snippet.
onPressed: () async {
SchedulerBinding.instance?.addPostFrameCallback((_) {
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
duration: const Duration(milliseconds: 1),
curve: Curves.fastOutSlowIn);
});
},
5. To jump listview from bottom to Top, you can use the below snippet.
onPressed: () async {
SchedulerBinding.instance?.addPostFrameCallback((_) {
_scrollController.animateTo(
_scrollController.position.minScrollExtent,
duration: const Duration(milliseconds: 1),
curve: Curves.fastOutSlowIn);
});
},
Let’s see a complete example of a scrolling list view of both sides.
11. Conclusion:
We have learned an exciting ListView feature in this article that you
may have seen on multiple websites and blogs. We as a leading Flutter
business app development company known for custom application
solutions for small, medium and large enterprises. Consult our
developers for productive and operational app solutions. So now you
can add the same functionality to your app. Hope you like this article.
Source: https://flutteragency.com/programmatically-scrolling-end-
of-listview/