Use Expanded() or Spacer() inside ListView or SingleChildScrollView

Lakshydeep Vikram
2 min readJun 18, 2021

We’ll gonna discuss about how to use Expanded widget inside ListView() or SingleChildScrollView(). Just a magic of few lines of code need to be added. Here we go:

Key Difference between Expanded() and Spacer()

Expanded() and Spacer() works same or rather to say it’s exactly same just one difference is that we have to wrap widget with Expanded whereas we just have to use Spacer() independently.

Way to use Expanded() inside ListView() or SingleChildScrollView()

Instead of SingleChildScrollView or ListView ,wrap the widget with CustomScrollView like in the below image and you’re able to use expanded() inside scrollable widgets.

You can get the code here . In this way, you can able to make scrollable widgets using Expanded and Spacer inside ListView/SingleChildScrollView.

Thanks for reading the article.

You can connect me LinkedIN and do follow.
Buy the book “Make Yourself The Software Developer: Let’s Dive into Flutter & MNCsbuy.
Kindly give feedback.
Keep learning and coding.
Thanks!!!

--

--

Lakshydeep Vikram
Lakshydeep Vikram

Written by Lakshydeep Vikram

Software Developer | Google Dev Library Author | Flutter Enthusiast