Home > Software engineering >  How to make a page vertically scrollable in flutter?
How to make a page vertically scrollable in flutter?

Time:05-27

I have made a dashboard page in flutter for a shopping app. I have written my code inside column but due to that the code is not scrollable and pixels keep overflowing. I have tried using ListView instead of column and I have also tried Using column inside ListView but as I try this both the output of the whole page disappears.

This is the snippet of the code

CodePudding user response:

You can try listview with shrinkwrap = true instead of using column

CodePudding user response:

If you use a Widget Tree like this:

SingleChildScrollView -> Column -> Expanded (one of the many Childs)

it will probably generate an error because Expanded is trying to expand to fill as much space as it can, and SingleChildScrollView gives all needed space (vertically, in this case) to his child. So it ends up with the Expanded widget trying to expand to infinite.

In order to fix this problem, you should programmatically calculate the height (the constraints) and wrap your SingleChildScrollView with a ConstainedBox.

Follow this guide. It contains almost all cases.

  • Related