How to add padding top of the ListView.builder in Flutter?

If you want to add padding to the inner content that scrolls up and down with the items, you can just add padding to the ListView itself.

If you wrap the ListView in a Padding or Container, it will create a gap between the edge where the content disappears and the widget above.

...
ListView.builder(
    padding: EdgeInsets.only(top: 10),
    itemCount: cards.length,
    itemBuilder: (context, index) {
       return MyCard(
           title: cards[index].title,
       );
    },
)
...

Leave a Comment