GetDirections method
Implementation
@override
Future<dynamic> GetDirections(List<CoordinateRF> coordinates) async {
Response returnResponse;
const String journeyMode = 'driving-car';
try {
Map<String, String> headers = {
"Accept-Language": "en-US",
'Authorization': Configuration.GeoCodingSource.OSMConfig.RouteKey!,
'Content-Type': 'application/json',
};
final body = jsonEncode({
"coordinates": coordinates.map((e) => [e.lng, e.lat]).toList(),
});
http.Response response = await http
.post(
Uri.parse(
'${Configuration.GeoCodingSource.OSMConfig.RouteUrl!}$journeyMode//geojson'),
headers: headers,
body: body)
.timeout(
const Duration(seconds: 30),
onTimeout: () {
throw FetchDataException('Request timeout');
},
);
returnResponse = Response(
_returnResponse(response), response.statusCode, response.headers);
} on SocketException {
throw FetchDataException('No Internet connection');
}
return returnResponse;
}