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.
Asked: 2021-11-30 11:00:00 +0000
Seen: 11 times
Last updated: Jul 25 '22