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

hide side image if have 1 item only? #282

Open eggyot opened 2 years ago

eggyot commented 2 years ago

how to hide side image if I only have 1 item? if not hide, so it's like have 3 item

I already try change to viewportFraction: 1 but it's change width to full width, I wan't change size width, only hide side image

see my image https://i.stack.imgur.com/JiEHG.png

this my code

Swiper(
                                autoplay: true,
                                itemBuilder: (BuildContext context,
                                    int index) {
                                  return InkWell(
                                    child: Card(
                                        margin: new EdgeInsets.only(
                                            bottom: 30
                                        ),
                                        shape: RoundedRectangleBorder(
                                            borderRadius: BorderRadius
                                                .circular(20)
                                        ),
                                        child: (
                                            ClipRRect(
                                                child: (
                                                    CachedNetworkImage(
                                                      imageUrl: dataPromo[index].bannerPath,
                                                        fit: BoxFit.fill,
                                                    )
                                                )
                                            )
                                        )
                                    ),
                                  );
                                },
                                itemCount: dataPromo.length,
                                viewportFraction: 0.8,
                                scale: 0.9,
                              ),