fetchDirections method
Future<MFDirectionsResult>
fetchDirections(
- MFLocationComponent origin,
- MFLocationComponent destination, {
- List<
MFLocationComponent> ? waypoints, - MFTravelMode mode = MFTravelMode.car,
- MFRouteWeighting weighting = MFRouteWeighting.fastest,
- MFLanguageResult language = MFLanguageResult.vi,
- MFRouteRestriction? restriction,
Get router.
Implementation
Future<MFDirectionsResult> fetchDirections(
MFLocationComponent origin,
MFLocationComponent destination, {
List<MFLocationComponent>? waypoints,
MFTravelMode mode = MFTravelMode.car,
MFRouteWeighting weighting = MFRouteWeighting.fastest,
MFLanguageResult language = MFLanguageResult.vi,
MFRouteRestriction? restriction,
}) async {
final Map<String, Object> data = <String, Object>{
'origin': origin.toJson(),
'destination': destination.toJson(),
'mode': mode.index,
'weighting': weighting.index,
'language': language.index,
};
if (waypoints != null) {
data['points'] = locationsToJson(waypoints);
}
if (restriction != null) {
data['restriction'] = restriction.toJson();
}
final response = await _ServicesChannel.invokeService('route#route', data);
validateResponse(response);
return DirectionsResult.fromMap(response!['result'])!;
}