Reputation: 31
While I can detect tab changes with:
controller.addListener((){
print('my index is'+ controller.index.toString());
});
How do I detect if the same tab is tapped? I'd like to have an action when user clicks on the home tab to go to the top of the scroll page while user is at home.
Upvotes: 2
Views: 3630
Reputation: 7492
You can implement to use onTap method in TabBar class.
TabBar(
onTap: (index) {
print(controller.index);
print(index);
if (controller.index == index) {
print('Same Tab Clicked');
}
},
tabs: [
...
]
});
Upvotes: 5