-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Use case
CupertinoPageRoute.title (actually CupertinoRouteTransitionMixin.title) is used to report previous title for CupertinoNavigationBar.previousPageTitle and there is no good way to update it from the same page.
Changes are propagated by using CupertinoRouteTransitionMixin.didChangePrevious which is only ever called by Navigator from push/pop/replace/etc. actions (via _flushHistoryUpdates -> _flushRouteAnnouncement).
One can probably use replace but it's explicitly forbidden to replace current route in the docs:
The old route must not be currently visible, as this method skips the animations and therefore the removal would be jarring if it was visible.
Explicitly populating CupertinoNavigationBar.previousPageTitle in a widget tree is a suboptimal solution because you almost never know what was the previous page.
An actual use case is that we have product pages that loads data after page is opened (including title, which is a shimmer animation at the beginning), so we need to propagate this new title back to Route object.
Proposal
- Make
Route.changedInternalStatetriggerRoute.didChangePreviousandRoute.didChangeNextwhen needed. - Update
CupertinoPageRoutesuch that it would be possible to passValueListenableas a title argument. - Listen to title value and trigger
changedInternalStateon updates.
Alternatively add some other hook to trigger current route update.
I believe updating Route so that it could broadcast it's state updates to neighboring routes is a more future-proof solution which would add more new possibilities for cross-route interactions.