best-flutter / flutter_swiper

The best swiper for flutter , with multiple layouts, infinite loop. Compatible with Android & iOS.
MIT License
3.51k stars 710 forks source link

Viewport not working with custom layout #279

Open Davete0302 opened 3 years ago

Davete0302 commented 3 years ago

I wanted to show 3 items in swipper so I adjusted na viewportFraction/itemWidth to .6 but does not seem to work. Just wanted to show 3 items like the default swipper while retaining the swipe animation.

new Swiper(
  layout: SwiperLayout.CUSTOM,
  customLayoutOption: new CustomLayoutOption(
      startIndex: -1,
      stateCount: 3
  ).addRotate([
    -45.0/180,
    0.0,
    45.0/180
  ]).addTranslate([
    new Offset(-370.0, -40.0),
    new Offset(0.0, 0.0),
    new Offset(370.0, -40.0)
  ]),
  itemWidth: 300.0,
  itemHeight: 200.0,
  itemBuilder: (context, index) {
    return new Container(
      color: Colors.grey,
      child: new Center(
        child: new Text("$index"),
      ),
    );
  },
  viewportFraction: 0.6,
  itemCount: 10)