parent property

AdvancedNavigatorState? parent
final

The navigator instance to which all navigation events from this navigator will be reported.

If specified, this navigator will work as an extension of the given navigator. It will notify the parent navigator of any changes to its current path. The respective path name will be appended to the parent's currentConfiguration for external use, most commonly for dispalying the browser url. On the flip side, navigation events which cannot be fully handled by the parent but where the first n segments match a path group with this navigator in it, will be forwarded to this navigator. As a result, this navigator effectively manages a subtree appended to the navigation route which contains this navigator.

This allows for hierarchical organization of pages which is particularly useful for working with Providers like in the BLoC pattern. Providers can be injected into the widget tree inbetween the two navigators and can therefore depend on route information such as an id in the path name.

Example:

'/'
'/products'
'/products/{productId}'
'/products/{productId}/edit' // <-- nested navigator appends '/edit'

Another use case is when part of the UI should persist between routes. This is sometimes desired for bottom navigation bars or side drawers, just to give an example.

In most cases, parent should be the nearest instance of AdvancedNavigator, i.e.

AdvancedNavigator(
  parent: AdvancedNavigator.of(context),
  ...
);

Implementation

final AdvancedNavigatorState? parent;