RouteNodeCompatibilityExtension extension
Extension on RouteNode that provides compatibility layer utilities
for distinguishing between page-based and pageless routes.
Route Types
YxNavigation needs to distinguish between two types of routes:
-
Page-based routes - Created declaratively via RouteDeclaration. These are part of Navigator 2.0 architecture.
-
Pageless routes - Created imperatively via Navigator 1.0 API (e.g.,
Navigator.push(MaterialPageRoute())).
This extension provides utilities to:
- Check if a route is page-based or pageless via
isPageBased - Access the original Navigator 1.0 Route via
nativeRoute - Retrieve the Page wrapper created by compatibility layer via
pageFactory - Get the result Completer for pop operations via
resultCompleter
Usage
These utilities are primarily used internally by NavigatorCompatibilityOverrides to manage lifecycle and state synchronization of pageless routes.
Example of checking route type:
final node = RouteNode.fromRoute(route: MyRoutes.home);
if (node.isPageBased) {
print('Declarative route from RouteDeclaration');
} else {
final originalRoute = node.nativeRoute;
print('Pageless route: ${originalRoute?.settings.name}');
}
See also:
- NavigatorCompatibilityOverrides, which uses these utilities
RouteNode, the state tree node this extension operates on
- on
-
- RouteNode