【问题标题】:Show 3 items in swipper在 swipper 中显示 3 个项目
【发布时间】:2021-11-09 11:42:48
【问题描述】:

我在flutter swipper(flutter_swiper:^1.1.6)上看到了这个示例代码。我想在保留滑动动画的同时显示 3 个项目,例如默认滑动器而不是 1 个项目。

.

目前自定义布局上仅显示 1 个项目..

 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)

【问题讨论】:

  • yama na te hahhhah

标签: flutter flutter-layout flutter-dependencies flutter-animation


【解决方案1】:

这里需要viewportFraction 参数

Swiper(
  itemBuilder: (BuildContext context, int index) {
    return new Image.network(
      "http://via.placeholder.com/288x188",
      fit: BoxFit.fill,
    );
  },
  itemCount: 10,
  viewportFraction: 0.8,
  scale: 0.9,
)

【讨论】:

  • 已经尝试添加 viewportFraction 还是一样的结果。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-13
  • 1970-01-01
相关资源
最近更新 更多