scrollcontroller not attached to any scroll views (Swiper)

I’m using a Swiper package to achieve a carousel effect on my images.
I’m trying to update the current index of my Swiper by passing a callback function to it’s child.

but when I try to call the function, it returns this ” scrollcontroller not attached ” error.

I’ve added a SwiperController but still the same.

Here is my code:

SwiperController swiperController;

  Widget build(BuildContext context) {
    return Container(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        child: Swiper(
          controller: swiperController,
          index: _index,
          scrollDirection: Axis.horizontal,
          itemBuilder: (BuildContext c, int i) {
            return StoriesPerUser(
              storiesList: widget.storiesList,
              selectedIndex: i,
              updateFunction: callBack,
          itemCount: widget.storiesList.length,
          loop: false,
          duration: 1000,

  callBack() {
    setState(() {

Please help.

One reply on “scrollcontroller not attached to any scroll views (Swiper)”

Leave a Reply

Your email address will not be published. Required fields are marked *