Reload tab routes
filippomenchini opened this issue · comments
Hi!
First of all, congrats for this library. One of the best ones available, I really like it!
I'm trying to create this behaviour:
if a user taps on a bottombar item two times, the page needs to be reloaded.
I was experimenting with AutoRouteObserver, but I can observe only when the selected page changes.
Is there a way to observe when a user taps a button on the bottombar?
Yes, i also need this
@filippomenchini I understand your requirement but I don't think it has to do with routing.
anyways tabsRouter will only be notified when the active route changes so I don't think there's a straight way to do this, but you can use something like a refresh notifier I guess.
final refreshNotifier = ValueNotifier<int?>(null);
onTap: (index){
// if tab already active set refreshNotifier
if(index == tabsRouter.activeIndex){
refreshNotifier.value = index;
}else{
tabsRouter.setActiveIndex(index);
}
}
inside of your tabs
initiState(){
refreshNotifier.addListner((){
if(refreshNotifier.value == THIS_TAB_INDEX){
refresh();
}
});
}
Hi @Milad-Akarie Thanks for answering!
Actually, yesterday I ended up using the same solution that you came up with.
Thanks again for your help!