drawIndependentRoutes method

  1. @override
Future<void> drawIndependentRoutes(
  1. List<DirectionsRoute> routes, {
  2. int primaryRouteIndex = 0,
})
override

Draws the route on the map based on the provided routes. it clears the previous route before drawing the new one. and then draws the route line, waypoints, and route duration symbol. This method is used when there are multiple origin and destination routes. The primaryRouteIndex parameter is used to determine the primary route to be drawn. Default is 0.

Implementation

@override
Future<void> drawIndependentRoutes(List<DirectionsRoute> routes,
    {int primaryRouteIndex = 0}) async {
  assert(primaryRouteIndex >= 0 && primaryRouteIndex < routes.length,
      "primaryRouteIndex should be between 0 and routes.length - 1 inclusive.");

  if (controller.disposed) {
    return;
  }

  if (routes.isEmpty) {
    return;
  }

  await clearRoute();
  _routes.addAll(routes);
  _primaryRouteIndex = primaryRouteIndex;
  _isIndependentRoute = true;
  await _drawRoutesFeatureCollections();
  await _drawWayPointsWithRoutes();
  await _drawRouteDurationSymbol();
}