How can I go back to first view in pageview when I go to a different tab from navigation rail widget?

75 views
Skip to first unread message

Scott J

unread,
Feb 19, 2021, 3:05:48 PM2/19/21
to Flutter Development (flutter-dev)
Hello,
I have a navigation rail widget that I use to go to different tabs in my app and on a certain tab I have a page view. In the page view I have a carousal. When I go to a different tab the page view page stays the same( ex. If I go to page 2, go to another tab, than come back to the tab with the pageview, it stays on page 2, naturally) I want to it go back to its first view when it changes tabs.  I thought changing the initial page in initstate would do it, but when I start the app all the widgets are built already...Any ideas how I can implement this? 

Suzuki Tomohiro

unread,
Feb 19, 2021, 10:09:50 PM2/19/21
to Scott J, Flutter Development (flutter-dev)
Use a GlobalKey to call some method of your PageView when you change tabs.

On Fri, Feb 19, 2021 at 15:05 Scott J <sje...@gmail.com> wrote:
Hello,
I have a navigation rail widget that I use to go to different tabs in my app and on a certain tab I have a page view. In the page view I have a carousal. When I go to a different tab the page view page stays the same( ex. If I go to page 2, go to another tab, than come back to the tab with the pageview, it stays on page 2, naturally) I want to it go back to its first view when it changes tabs.  I thought changing the initial page in initstate would do it, but when I start the app all the widgets are built already...Any ideas how I can implement this? 

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/cc4908b4-a931-493b-8c41-d3c30298c22fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages