setNavigationRoadBlock static method

void setNavigationRoadBlock(
  1. int length, {
  2. int startDistance = -1,
  3. TaskHandler? taskHandler,
})

Temporary route roadblock configuration.

Sets a virtual roadblock on the current navigation route, forcing route recalculation to avoid the blocked section. The roadblock extends for the specified length starting from a given distance along the route. Useful for simulating traffic incidents or testing route recalculation behavior.

Parameters

  • length: Roadblock length in meters.
  • startDistance: Distance from route start where the roadblock begins, in meters. Defaults to -1, meaning the current navigation position.
  • taskHandler: Optional handler for the navigation session. If omitted, applies to the active session.

See also:

Implementation

static void setNavigationRoadBlock(
  final int length, {
  final int startDistance = -1,
  final TaskHandler? taskHandler,
}) {
  taskHandler as TaskHandlerImpl?;

  staticMethod(
    'NavigationService',
    'setNavigationRoadBlock',
    args: <String, dynamic>{
      'length': length,
      'startDistance': startDistance,
      'navigationListener': taskHandler?.id ?? 0,
    },
  );
}