csells / go_router

The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
https://gorouter.dev
441 stars 97 forks source link

notifyListeners is not called when using router.go #126

Closed esDotDev closed 3 years ago

esDotDev commented 3 years ago

It seems that notifyListeners is only called when using the various imperative .push/.pop, but not when calling router.go().

esDotDev commented 3 years ago

The issue was caused by not assigning a pageKey, which caused the navigator to be unaware that it's pageStack had changed. Which I suppose is expected :)

This could be worked around by just adding a manual notifyListeners call to _go fwiw.

csells commented 3 years ago

I'm just using the underlying Navigator support for NavigatorObserver.

esDotDev commented 3 years ago

It looks like you do call _safeNotifyListeners from within goRouterDelegate.go, this causes the GoRouterDelegate to call notifyListeners, but it does not cause GoRouter to do the same.

Which creates this edge case:

If you wanted to remove this edge case, you could probably do something like:

void go(String location, {Object? extra}){
   routerDelegate.go(location, extra: extra);
   notifyListeners(); // just manually let everyone know we changed, since navigator.observers might miss it.
}