Outline
When we develop the app that has the list in Flutter, we often use the SingleChildScrollView
widget. At that time, to implement specific features like Pull to refresh
, we need to make it always scrollable regardless of the child widget size.
In this blog post, I will introduce how to make the list always scrollable regardless of the child widget size in the SingleChildScrollView
widget.
AlwaysScrollableScrollPhysics
The SingleChildScrollView
widget has the physics
option.
- SingleChildScrollView: https://api.flutter.dev/flutter/widgets/SingleChildScrollView/physics.html
By using this option, we can make the list always scrollable regardless of the child widget size. When you set AlwaysScrollableScrollPhysics
to this option, you can make the list scollable regardless of the child widget size.
SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: ...,
),
In additional to the SingleChildScrollView
widget, most scrollable widgets such as the ListView
widget have the physics
option.
So, if you need to change the behavior of scrolling, looking at the physics
option will be helpful.
Completed
Done! we’ve seen how to make the SingleChildScrollView
widget always scrollable regardless of the child widget size by configuring AlwaysScrollableScrollPhysics
to the physics
option. You can use this to implement Pull to refresh
feature. If you want to know more about implementing the Pull to refresh
feature, please see the following blog post.
Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!
App promotion
Deku
.Deku
created the applications with Flutter.If you have interested, please try to download them for free.