Get CurrentPage/CurrentState with introduction_screen package in Flutter

Viewed 57

I'm having trouble finding the CurrentPage/CurrentState index from a popular library called introduction_screen: ^3.0.2.

I want to replace the parameter of "globalFooter" with a certain condition.

As an example :

If the Intro screen is at the initial index (0), then display the Button widget. If not, then don't show any widgets.

globalFooter: isLastPage ? ElevatedButton() : Text(""),

How do I get the index of the CurrentPage/CurrentState? Previously, as a newbie in Flutter I had tried using "introKey.currentState?.animateScroll(0)" but that failed.

1 Answers

IntroductionScreen has a parameter called onChange which takes a function of type Function(int). Just wrap your introduction screen inside a stateful widget, create a bool field with isLastPage and pass a function to onChange where you set isLastPage to true if the given int equals the index of the last page.

Related