Ask Your Question
1

How can I remove the padding between items while scrolling through a list view in Flutter?

asked 2022-06-15 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-11-18 03:00:00 +0000

devzero gravatar image

You can remove the padding between items in a ListView by setting the padding property of the ListView to EdgeInsets.zero and the itemExtent property to the desired item height. Here's an example:

ListView.builder(
  padding: EdgeInsets.zero,
  itemExtent: 50,
  itemCount: items.length,
  itemBuilder: (context, index) {
    return ListTile(
      title: Text(items[index]),
    );
  },
);

Note that setting the itemExtent property can improve the performance of your ListView, but it may not be suitable for dynamic or variable height items. In that case, you can use a SliverList inside a CustomScrollView with a SliverPadding instead.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-06-15 11:00:00 +0000

Seen: 11 times

Last updated: Nov 18 '21