Closed osaxma closed 2 years ago
Hmm... That looks like a regression. @lulupointu any thoughts on this?
This is missing:
@override
void didUpdateWidget(covariant FamilyTabsPage oldWidget) {
if (oldWidget.index != widget.index && widget.index != _controller.index) {
_controller.animateTo(
widget.index,
duration: const Duration(milliseconds: 300),
);
}
super.didUpdateWidget(oldWidget);
}
Also this is not needed:
@override
void didChangeDependencies() {
super.didChangeDependencies();
_controller.index = widget.index;
}
First, let's understand why this example did work (almost):
didChangeDependencies
could change the index_tap
calls context.go
which internally calls context.dependOnInheritedWidgetOfExactType
causing the widget state associated with the context to rebuild when the InheritedWidget
changes AND returns true
in updateShouldNotify
.So if the user used at least once _tab
, then changed the url, didChangeDependencies
was called and the index changes.
Now everything changed 8 days ago, look at this change
This basically cancelled any call to didChangeDependencies
that was caused by GoRouter
.
Now you know why Provider
as listen: false
, and also why it warns you when you try to use listen: true
outside a build
method :wink:
Nice! Not only did you provide a bug fix but you also found why it used to work and suddenly stopped. Amazing!
@osaxma this fix is part of v2.2.9. can you confirm that it's fixed on your end?
Yes, it's working now!
Issue can be observed in this screen recording:
https://user-images.githubusercontent.com/46427323/142935109-bfb5375a-ce85-4e1f-8cc4-69e1ec305f7b.mov
Flutter version: 2.5.3 (stable) go_router version: 2.2.8