Search code examples
flutterflutter-pageview

How to use flutter _pageControler.jumpToPage() from another screen?


Let's say I have 4 files in my project.

navbar, firstPage, secondPage, thirdPage.

In the navbar I have a side drawer with navigation for the pageview and a pageview for firstPage secondPage and thirdPage.

How do I access navbar PageController.jumpToPage() from button onTab function in other pages?


Solution

  • You can access navbar PageController.jumpToPage() from button onTab function in other pages by 2 ways:

    1 passing PageController to the page that have onTab function

    2 using dependence injection that can share PageController with any page, have a look at get_it package for more info.