Reputation: 81
I have a list of photos and want that one photo should be shown at a time. By this I mean if a user scrolls down then the upper photo should not be seen only the new one should be seen. It should not be like you can hold the scroll between two images. I want something like instagram reels where one reel is visible at a time.
CODE:-
ListView.builder(
shrinkWrap: true,
itemCount: postList.length,
itemBuilder: (context,index)
{
return postList[index];
},
);
Upvotes: 0
Views: 2217
Reputation: 2982
You can use the Physics Property of Listview. use this
physics: PageScrollPhysics(),
Upvotes: 2
Reputation: 5993
its your listView
ListView.builder(
shrinkWrap: true,
itemCount: postList.length,
itemBuilder: (context,index)
{
return postList[index];
},
);
You can use pageView with Scroll direction vertical,
postList(){
return PageView(
scrollDirection: Axis.vertical,
itemBuilder: yourPageItems...,
itemCount: listItemCount,
}
Upvotes: 0
Reputation: 1291
You could achieve this using a PageView widget, or you could also use some plugin like tiktoklikescroller
Upvotes: 1