[Flutter] Make scrollable regardless of child widget size

2023-10-16 hit count image

Let's see how to make always scrollable of the list regardlres sof the child widget size in the SingleChildScrollView widget.

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.

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

You can use the applications that are created by this blog writer Deku.
Deku created the applications with Flutter.

If you have interested, please try to download them for free.

Posts