| final _routeTask = RouteTask.withUri( | |
| Uri.parse( | |
| 'https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World', | |
| ), | |
| ); | |
| // ... | |
| trafficRouteParameters = await _routeTask.createDefaultParameters() | |
| ..setStops(_routeStops) | |
| ..outputSpatialReference = SpatialReference(wkid: 27700) | |
| ..directionsDistanceUnits = UnitSystem.imperial; | |
| // ... | |
| var routeResult = await _routeTask.solveRoute(trafficRouteParameters); | |
| if (routeResult.routes.isEmpty) { | |
| if (mounted) { | |
| _showAlertDialog('No routes have been generated.', title: 'Info'); | |
| } | |
| return; | |
| } | |
| _routeGeometry = routeResult.routes.first.routeGeometry; | |
| if (_routeGeometry != null) { | |
| final routeGraphic = Graphic(geometry: _routeGeometry); | |
| _routeGraphicsOverlay.graphics.add(routeGraphic); | |
| } |