Skip to content

External Control

Ismael Shakverdiev edited this page Apr 17, 2022 · 1 revision

To control the slider from outside of itself, you have to create an instance of SlideController.

final slideController = SlideController(
  curve: Curves.easeOut,                // optional 
  duration: const Duration(seconds: 1), // optional
);

Then pass it to the actual WidgetSlider widget.

WidgetSlider(
  controller: slideController,
  itemCount: questions.length,
  itemBuilder: (context, index, activeIndex) {
    return Card(...);
  }
 // ...
)

Now, you can call its functionalities.

  • moveTo takes an integer index which represents the index of item you wanna move.
slideController.moveTo?.call(3);
  • moveToNext moves to next item.
slideController.moveToNext?.call();
  • moveToPrevious moves to previous item.
slideController.moveToPrevious?.call();

Clone this wiki locally