Ask Your Question
3

How can the full width of a Flutter horizontal ListView be utilized while disregarding padding?

asked 2021-11-30 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-07-25 15:00:00 +0000

scrum gravatar image

To utilize the full width of a Flutter horizontal ListView while disregarding padding, you can set the padding property of the ListView widget to EdgeInsets.zero which will remove any padding that might be present. Here is an example of how to achieve this:

ListView.builder(
  padding: EdgeInsets.zero, // set padding to zero
  scrollDirection: Axis.horizontal,
  itemCount: 10,
  itemBuilder: (BuildContext context, int index) {
    return Container(
      width: MediaQuery.of(context).size.width, // set container width to screen width
      child: Text('Item $index'),
    );
  },
)

This will create a horizontal ListView that utilizes the full width of the screen without any left or right padding.

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: 2021-11-30 11:00:00 +0000

Seen: 11 times

Last updated: Jul 25 '22