I need to start my page something like this,
But this is what my list view looks like, I need to center it like the first one, how can I achieve that
this is my listview.builder widget
Flexible(flex: 2,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 10,
itemBuilder: (context, index) {
return const RowShoppingtile();
},
),
),
can anyone suggest me way to do this
3
Answers
use this library to get your result
https://pub.dev/packages/carousel_slider
This will make the ListView scroll by one page at a time instead of scrolling through each item.
You can use
ScrollController
to scroll theListView
to a desired position. Make sure to call to scroll after build is finished.Above sample only works for odd number of ListView items. Otherwise you need to calculate the scroll position accordingly.