How ListView can Stop at each element in Flutter - flutter

My question is very simple but I did not find a result.
In a ListView.builder (with horizontal scroll) for example if there are 5 elements the user can scroll them all at once. I would like that the user can scroll only 1 by 1.
In short I would like the animation of the list to stop at each element.
Example of my list :
Widget _list()
{
return ListView.builder(
physics: const ClampingScrollPhysics(),
scrollDirection: _horizontalDisplay? Axis.horizontal : Axis.vertical,
itemCount: data!.length,
itemBuilder: (context, index)
{
return widgetToDisplay(index);
}
);
}

The ListView.builder can't make it, you need to use carousel_slider package

Related

Problem in listview.builder with multiple widgets

I have a list of items and based on a condition it should be displayed in Widget1() or Widget2(). It works fine up to there, the problem is when I get to the bottom of the list and want to scroll slowly up, the items rebuild and it jumps up and down the list.
Using the itemExent does solve the problem, but it's not the ideal solution. I need dynamic items.
Note: Widgets do not have a default size.
ListView.builder(
controller: scrollController,
cacheExtent: 10000,
addAutomaticKeepAlives: true,
dragStartBehavior: DragStartBehavior.start,
physics: AlwaysScrollableScrollPhysics(),
//itemExtent: 450.0,
itemBuilder: (context, index) {
if (index < list.length)
return MultiBlocProvider(
providers: [
/// some mandatory providers
],
child: some condition
? Widget1()
: Widget2());
return loading();
},
itemCount: list.length
);

Flutter Nested Listviews design float up when content grows

there I have 3 nested listview. Here is it's representation.
(Items, titles, subtitles are nested listview builder)
In default, title and leading icon is aligned to each other. Title's subtitles are also another list view. As you can see when my title has only one subtitle there is no problem. But if you look item 3 it has 3 subtitle so it's going to up. And my top padding change also my leading icon and my title are not aligned anymore.
My listview builders main representation:
child: ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
...
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: items.titles.length,
itemBuilder: (context, titleInd) {
.........
child: ListTile(
.....
subtitle: ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,)
....
),
}
Couldn't find the reason that effect my paddings and leading icon-title alignment. What can be reason of that and How can I fix this issue?

Cant scroll with ListView.builder()

I was wondering if anyone had an issue where they use a ListView.builder() and then it doesn't want to scroll
return ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: widget.product.category.length,
itemBuilder: (context, index) {
final item = widget.product.category[index];
return ListTile(title: Text(item));
},
)
I'd suggest you do the following:
Remove shrinkWrap and make sure the value passed to itemCount is large enough to make the widget scroll.
If you place the list view inside a vertically scrolling list, it's not going to scroll... In this case, you should probably be using slivers

Show one item at a time in a listView in flutter

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];
},
);
You can use the Physics Property of Listview. use this
physics: PageScrollPhysics(),
You could achieve this using a PageView widget, or you could also use some plugin like tiktoklikescroller
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,
}

Flutter How to vertical scroll a screen like a book

e-book
I want to make an e-book with scrolling screens that are images with Flutter
You should use PageView. Using page view you can either scroll page horizontally or vertically.
PageView.builder(
itemBuilder: (context, position) {
return _buildPage();
},
itemCount: listItemCount,
scrollDirection: Axis.vertical,
)