I'm trying to create a ListView of images that stays in a PageView so I can swipe left or right to move to other images.
But I currently end up with an error that it only displays as a column and swipe vertically not horizontally as I wanted.
Anyone who gets solutions or ideas, please help me.
Here is my code:
final PageController _controller = PageController(
initialPage: initialImageIndex, keepPage: true, viewportFraction: 1);
return SafeArea(
child: Scaffold(
body: PageView(
controller: _controller,
scrollDirection: Axis.horizontal,
onPageChanged: (index) {
print("changed to $index");
},
children: [
Row(
children: [
Container(
width: size.width,
child: ListView.builder(
controller: ScrollController(
),
scrollDirection: Axis.horizontal,
shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
itemCount: imagesInCategory.length,
itemBuilder: (context, index) {
return BuildImageDetail(
size: size, imageData: imagesInCategory[index]);
},
),
),
],
),
])),
I just got it with a function to render the widgets that Listview currently does now. Then in children of PageView, i just call this function.
Hope this helps somebody.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.