Flutter – How will you check from which screen you have clicked bottom navigation tab

Issue

I am trying to find how can I know from which screen user has clicked the bottom nav screen. Basically I have to send event from which screen user clicked on botton nav. I have 4 bottom nav.

Solution

There is no direct way to check a previously selected item in the bottom bar what you can do you can make use of

onTap: (index) => changeTab(index)

It gives an index of the item user taps, Save index to some variable, and next time when use tap on the item you can consider previously saved value as an item from which the user is tapping.

Answered By – Shripad Jadhav

Answer Checked By – Marilyn (FlutterFixes Volunteer)

Leave a Reply

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