willPushPagelessRoute method

bool willPushPagelessRoute({
  1. required RouteNodeReadable routeNodeReadable,
  2. required Route route,
  3. required String routeId,
})

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 - The RouteNodeReadable instance that provides access to the parent node of the created route node
  • route - The original Route instance from Navigator 1.0 API
  • routeId - 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;