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.
Asked
Active
Viewed 619 times
1
-
share the code please. – xbadal Oct 28 '20 at 12:04
-
You can use @Shripad Jadhav answer then save the page index with shared preference – Confidence Yobo Oct 28 '20 at 12:36
2 Answers
2
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.

Shripad Jadhav
- 316
- 1
- 8
0
You can check the last selected index in bottom navigation bar :
static int currentTab = 0;
static int lastIndex = 0;
When you implement the onPressed or onTap method on bottom bar:
onTap: (){
setState(() {
currentTab = index;
lastIndex = currentTab; // It keeps the last selected index.
}
});
}
And then u can call
currentTab = lastIndex.

Nisha Jain
- 637
- 6
- 14