flutter_card_swipper external SwiperPagination

774 views Asked by At

Is there a way to have the SwiperPagination as an external Widget outside of the Swiper() widget?

Swiper(
  controller: _swiperController,
  itemCount: _getTopWikiList.length,
  pagination: SwiperPagination(
    margin: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
    builder: DotSwiperPaginationBuilder(
        color: Colors.black26,
        activeColor: Colors.deepOrangeAccent,
        size: 6.0,
        activeSize: 9.0),
  ),
  viewportFraction: 1,
  layout: SwiperLayout.DEFAULT,
  scale: 1,
  itemBuilder: (BuildContext context, int index) {
    return Container(
      decoration: new BoxDecoration(
        shape: BoxShape.circle,
        image: new DecorationImage(
          fit: BoxFit.cover,
          image: new NetworkImage(
            _getTopWikiList[index].imgThumbUrl,
          ),
        ),
      ),
    );
  },
),

I would like to put

SwiperPagination(
margin: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
builder: DotSwiperPaginationBuilder(
    color: Colors.black26,
    activeColor: Colors.deepOrangeAccent,
    size: 6.0,
    activeSize: 9.0),
),

somewhere else as an own widget.

1

There are 1 answers

0
Ricky On

You can use dots_indicator

Just remove pagination in Swiper and put DotsIndicator() anywhere u want. You can get the current index from _swiperController.