willPushPagelessRoute method
Called BEFORE a pageless route is processed.
This is invoked before the route is converted to page-based navigation, allowing the observer to inspect, validate, or block the route.
Return false to prevent processing (route will fall back to native Navigator).
Return true to allow processing (default).
Parameters
routeNodeReadable- TheRouteNodeReadableinstance that provides access to the parent node of the created route noderoute- The original Route instance from Navigator 1.0 APIrouteId- Generated unique ID for this route in YxNavigation
Use Cases
- Validation: Block certain route types from processing
- Logging: Track route creation attempts before conversion
- Debugging: Inspect routes before they enter compatibility layer
Example
@override
bool willPushPagelessRoute({
required RouteNodeReadable routeNodeReadable,
required Route<dynamic> route,
required String routeId,
}) {
// Block unnamed routes
if (route.settings.name == null) {
debugPrint('Blocking unnamed route: ${route.runtimeType}');
return false;
}
// Log before processing
debugPrint('Will process: ${route.runtimeType} ($routeId)');
return true;
}
Implementation
bool willPushPagelessRoute({
required RouteNodeReadable routeNodeReadable,
required Route<dynamic> route,
required String routeId,
}) =>
true;