SlideShare a Scribd company logo
1 of 12
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 fulfills the necessary tasks by placing the
elements inside it in the correct order according to the developer’s
requirements. Also check out the the availability of experts to hire
Flutter app developers for your next project.
ListViews Widgets come in the following four
types:
1. ListView()
2. ListView.builder()
3. ListView.separated()
4. ListView.custom()
You can learn more about the listview widget and its type with more
details from here.
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.
Also check out the as important topic How to Use Hexadecimal Color
Strings in Flutter?
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);
});
},
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.
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
final ScrollController _scrollController = ScrollController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Coflutter'),
),
body: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
child: const Text('To Top'),
onPressed: () async {
SchedulerBinding.instance?.addPostFrameCallback((_) {
_scrollController.animateTo(
_scrollController.position.minScrollExtent,
duration: const Duration(milliseconds: 1),
curve: Curves.fastOutSlowIn);
});
},
),
ElevatedButton(
child: const Text('To Bottom'),
onPressed: () async {
SchedulerBinding.instance?.addPostFrameCallback((_) {
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
duration: const Duration(milliseconds: 1),
curve: Curves.fastOutSlowIn);
});
},
),
],
),
Expanded(
child: ListView.builder(
controller: _scrollController,
itemCount: 100,
itemBuilder: (BuildContext context, int index) {
return Card(
child: ListTile(
title: Text("Index : $index"),
),
);
},
),
),
const Divider(),
],
));
}
}
Output
Conclusion
We have learned an exciting ListView feature in this article that you
may have seen on multiple websites and blogs. So now you can add the
same functionality to your app. Hope you like this article.
Source: https://bosctechlabs.com/programmatically-scrolling-to-end-
of-listview/

More Related Content

More from BOSC Tech Labs

The iOS Advantage_ How Apple’s Ecosystem Is Setting the Stage for Next-Gen Bu...
The iOS Advantage_ How Apple’s Ecosystem Is Setting the Stage for Next-Gen Bu...The iOS Advantage_ How Apple’s Ecosystem Is Setting the Stage for Next-Gen Bu...
The iOS Advantage_ How Apple’s Ecosystem Is Setting the Stage for Next-Gen Bu...BOSC Tech Labs
 
The Role iOS App Development_ Hiring for the Future.pdf
The Role iOS App Development_ Hiring for the Future.pdfThe Role iOS App Development_ Hiring for the Future.pdf
The Role iOS App Development_ Hiring for the Future.pdfBOSC Tech Labs
 
React 19: Revolutionizing Web Development
React 19: Revolutionizing Web DevelopmentReact 19: Revolutionizing Web Development
React 19: Revolutionizing Web DevelopmentBOSC Tech Labs
 
2024 Custom Software Development Guide: Trends, Steps & Benefits
2024 Custom Software Development Guide: Trends, Steps & Benefits2024 Custom Software Development Guide: Trends, Steps & Benefits
2024 Custom Software Development Guide: Trends, Steps & BenefitsBOSC Tech Labs
 
What is the Easiest Way to Hire a React Developer?
What is the Easiest Way to Hire a React Developer?What is the Easiest Way to Hire a React Developer?
What is the Easiest Way to Hire a React Developer?BOSC Tech Labs
 
Top 10 React Carousel Component Libraries and their Usage Trends
Top 10 React Carousel Component Libraries and their Usage TrendsTop 10 React Carousel Component Libraries and their Usage Trends
Top 10 React Carousel Component Libraries and their Usage TrendsBOSC Tech Labs
 
The Comprehensive Tech Guide to iOS Mobile App Development: From Concept to L...
The Comprehensive Tech Guide to iOS Mobile App Development: From Concept to L...The Comprehensive Tech Guide to iOS Mobile App Development: From Concept to L...
The Comprehensive Tech Guide to iOS Mobile App Development: From Concept to L...BOSC Tech Labs
 
STEP BY STEP GUIDE TO HIRING EXPERIENCED FLUTTER DEVELOPERS
STEP BY STEP GUIDE TO HIRING EXPERIENCED FLUTTER DEVELOPERSSTEP BY STEP GUIDE TO HIRING EXPERIENCED FLUTTER DEVELOPERS
STEP BY STEP GUIDE TO HIRING EXPERIENCED FLUTTER DEVELOPERSBOSC Tech Labs
 
Top 10 Essential Traits to Look For Hire Remote React Developer
Top 10 Essential Traits to Look For Hire Remote React DeveloperTop 10 Essential Traits to Look For Hire Remote React Developer
Top 10 Essential Traits to Look For Hire Remote React DeveloperBOSC Tech Labs
 
Transform Your Mobile App Development with ChatGPT
Transform Your Mobile App Development with ChatGPTTransform Your Mobile App Development with ChatGPT
Transform Your Mobile App Development with ChatGPTBOSC Tech Labs
 
Which Is The Best AI Tool For Mobile App Development_.pdf
Which Is The Best AI Tool For Mobile App Development_.pdfWhich Is The Best AI Tool For Mobile App Development_.pdf
Which Is The Best AI Tool For Mobile App Development_.pdfBOSC Tech Labs
 
Revealing Development Efficiency: How AI Powers Innovation in Software Creati...
Revealing Development Efficiency: How AI Powers Innovation in Software Creati...Revealing Development Efficiency: How AI Powers Innovation in Software Creati...
Revealing Development Efficiency: How AI Powers Innovation in Software Creati...BOSC Tech Labs
 
Boost Your Website with Top React Carousel Libraries | BOSC
Boost Your Website with Top React Carousel Libraries | BOSCBoost Your Website with Top React Carousel Libraries | BOSC
Boost Your Website with Top React Carousel Libraries | BOSCBOSC Tech Labs
 
Maximize Development Efficiency with ReactJS.pdf
Maximize Development Efficiency with ReactJS.pdfMaximize Development Efficiency with ReactJS.pdf
Maximize Development Efficiency with ReactJS.pdfBOSC Tech Labs
 
Check How Real-Time Video Streaming Can Benefit Your Business.pdf
Check How Real-Time Video Streaming Can Benefit Your Business.pdfCheck How Real-Time Video Streaming Can Benefit Your Business.pdf
Check How Real-Time Video Streaming Can Benefit Your Business.pdfBOSC Tech Labs
 
Boost Startup Success: Hire Skilled ReactJS Developers Today
Boost Startup Success: Hire Skilled ReactJS Developers TodayBoost Startup Success: Hire Skilled ReactJS Developers Today
Boost Startup Success: Hire Skilled ReactJS Developers TodayBOSC Tech Labs
 
Why Startups Should Consider Flutter App Developers?
Why Startups Should Consider Flutter App Developers?Why Startups Should Consider Flutter App Developers?
Why Startups Should Consider Flutter App Developers?BOSC Tech Labs
 
Why flutter a game changer in app development By Flutter Agency.pdf
Why flutter a game changer in app development By Flutter Agency.pdfWhy flutter a game changer in app development By Flutter Agency.pdf
Why flutter a game changer in app development By Flutter Agency.pdfBOSC Tech Labs
 
React 18: New Features & Innovations
React 18: New Features & InnovationsReact 18: New Features & Innovations
React 18: New Features & InnovationsBOSC Tech Labs
 
How Much Does it Cost to Hire the Best React.js Developer
How Much Does it Cost to Hire the Best React.js DeveloperHow Much Does it Cost to Hire the Best React.js Developer
How Much Does it Cost to Hire the Best React.js DeveloperBOSC Tech Labs
 

More from BOSC Tech Labs (20)

The iOS Advantage_ How Apple’s Ecosystem Is Setting the Stage for Next-Gen Bu...
The iOS Advantage_ How Apple’s Ecosystem Is Setting the Stage for Next-Gen Bu...The iOS Advantage_ How Apple’s Ecosystem Is Setting the Stage for Next-Gen Bu...
The iOS Advantage_ How Apple’s Ecosystem Is Setting the Stage for Next-Gen Bu...
 
The Role iOS App Development_ Hiring for the Future.pdf
The Role iOS App Development_ Hiring for the Future.pdfThe Role iOS App Development_ Hiring for the Future.pdf
The Role iOS App Development_ Hiring for the Future.pdf
 
React 19: Revolutionizing Web Development
React 19: Revolutionizing Web DevelopmentReact 19: Revolutionizing Web Development
React 19: Revolutionizing Web Development
 
2024 Custom Software Development Guide: Trends, Steps & Benefits
2024 Custom Software Development Guide: Trends, Steps & Benefits2024 Custom Software Development Guide: Trends, Steps & Benefits
2024 Custom Software Development Guide: Trends, Steps & Benefits
 
What is the Easiest Way to Hire a React Developer?
What is the Easiest Way to Hire a React Developer?What is the Easiest Way to Hire a React Developer?
What is the Easiest Way to Hire a React Developer?
 
Top 10 React Carousel Component Libraries and their Usage Trends
Top 10 React Carousel Component Libraries and their Usage TrendsTop 10 React Carousel Component Libraries and their Usage Trends
Top 10 React Carousel Component Libraries and their Usage Trends
 
The Comprehensive Tech Guide to iOS Mobile App Development: From Concept to L...
The Comprehensive Tech Guide to iOS Mobile App Development: From Concept to L...The Comprehensive Tech Guide to iOS Mobile App Development: From Concept to L...
The Comprehensive Tech Guide to iOS Mobile App Development: From Concept to L...
 
STEP BY STEP GUIDE TO HIRING EXPERIENCED FLUTTER DEVELOPERS
STEP BY STEP GUIDE TO HIRING EXPERIENCED FLUTTER DEVELOPERSSTEP BY STEP GUIDE TO HIRING EXPERIENCED FLUTTER DEVELOPERS
STEP BY STEP GUIDE TO HIRING EXPERIENCED FLUTTER DEVELOPERS
 
Top 10 Essential Traits to Look For Hire Remote React Developer
Top 10 Essential Traits to Look For Hire Remote React DeveloperTop 10 Essential Traits to Look For Hire Remote React Developer
Top 10 Essential Traits to Look For Hire Remote React Developer
 
Transform Your Mobile App Development with ChatGPT
Transform Your Mobile App Development with ChatGPTTransform Your Mobile App Development with ChatGPT
Transform Your Mobile App Development with ChatGPT
 
Which Is The Best AI Tool For Mobile App Development_.pdf
Which Is The Best AI Tool For Mobile App Development_.pdfWhich Is The Best AI Tool For Mobile App Development_.pdf
Which Is The Best AI Tool For Mobile App Development_.pdf
 
Revealing Development Efficiency: How AI Powers Innovation in Software Creati...
Revealing Development Efficiency: How AI Powers Innovation in Software Creati...Revealing Development Efficiency: How AI Powers Innovation in Software Creati...
Revealing Development Efficiency: How AI Powers Innovation in Software Creati...
 
Boost Your Website with Top React Carousel Libraries | BOSC
Boost Your Website with Top React Carousel Libraries | BOSCBoost Your Website with Top React Carousel Libraries | BOSC
Boost Your Website with Top React Carousel Libraries | BOSC
 
Maximize Development Efficiency with ReactJS.pdf
Maximize Development Efficiency with ReactJS.pdfMaximize Development Efficiency with ReactJS.pdf
Maximize Development Efficiency with ReactJS.pdf
 
Check How Real-Time Video Streaming Can Benefit Your Business.pdf
Check How Real-Time Video Streaming Can Benefit Your Business.pdfCheck How Real-Time Video Streaming Can Benefit Your Business.pdf
Check How Real-Time Video Streaming Can Benefit Your Business.pdf
 
Boost Startup Success: Hire Skilled ReactJS Developers Today
Boost Startup Success: Hire Skilled ReactJS Developers TodayBoost Startup Success: Hire Skilled ReactJS Developers Today
Boost Startup Success: Hire Skilled ReactJS Developers Today
 
Why Startups Should Consider Flutter App Developers?
Why Startups Should Consider Flutter App Developers?Why Startups Should Consider Flutter App Developers?
Why Startups Should Consider Flutter App Developers?
 
Why flutter a game changer in app development By Flutter Agency.pdf
Why flutter a game changer in app development By Flutter Agency.pdfWhy flutter a game changer in app development By Flutter Agency.pdf
Why flutter a game changer in app development By Flutter Agency.pdf
 
React 18: New Features & Innovations
React 18: New Features & InnovationsReact 18: New Features & Innovations
React 18: New Features & Innovations
 
How Much Does it Cost to Hire the Best React.js Developer
How Much Does it Cost to Hire the Best React.js DeveloperHow Much Does it Cost to Hire the Best React.js Developer
How Much Does it Cost to Hire the Best React.js Developer
 

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 fulfills the necessary tasks by placing the elements inside it in the correct order according to the developer’s requirements. Also check out the the availability of experts to hire Flutter app developers for your next project.
  • 3. ListViews Widgets come in the following four types: 1. ListView() 2. ListView.builder() 3. ListView.separated() 4. ListView.custom()
  • 4. You can learn more about the listview widget and its type with more details from here. 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. Also check out the as important topic How to Use Hexadecimal Color Strings in Flutter? To manage our ListView, we will want a ScrollController.
  • 5. 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); }); },
  • 6. 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); }); },
  • 7. Let’s see a complete example of a scrolling list view of both sides. class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { final ScrollController _scrollController = ScrollController(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Coflutter'), ), body: Column( children: [ Row(
  • 8. mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ ElevatedButton( child: const Text('To Top'), onPressed: () async { SchedulerBinding.instance?.addPostFrameCallback((_) { _scrollController.animateTo( _scrollController.position.minScrollExtent, duration: const Duration(milliseconds: 1), curve: Curves.fastOutSlowIn); }); }, ),
  • 9. ElevatedButton( child: const Text('To Bottom'), onPressed: () async { SchedulerBinding.instance?.addPostFrameCallback((_) { _scrollController.animateTo( _scrollController.position.maxScrollExtent, duration: const Duration(milliseconds: 1), curve: Curves.fastOutSlowIn); }); }, ), ], ),
  • 10. Expanded( child: ListView.builder( controller: _scrollController, itemCount: 100, itemBuilder: (BuildContext context, int index) { return Card( child: ListTile( title: Text("Index : $index"), ), ); }, ), ), const Divider(), ], )); } }
  • 12. Conclusion We have learned an exciting ListView feature in this article that you may have seen on multiple websites and blogs. So now you can add the same functionality to your app. Hope you like this article. Source: https://bosctechlabs.com/programmatically-scrolling-to-end- of-listview/