0

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]);
                },
              ),
            ),
          ],
        ),
    ])),
Chirag Bargoojar
  • 1,026
  • 2
  • 8
  • 19
ninoorta
  • 662
  • 1
  • 5
  • 13

1 Answers1

0

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.

ninoorta
  • 662
  • 1
  • 5
  • 13