fetchGraphRoute method

Future<List<MFGraphRouteResult>> fetchGraphRoute(
  1. List<MFLocationComponent> locations, {
  2. MFTravelMode mode = MFTravelMode.car,
  3. MFRouteWeighting weighting = MFRouteWeighting.fastest,
  4. MFLanguageResult language = MFLanguageResult.vi,
  5. MFRouteRestriction? restriction,
})

Graph route.

Implementation

Future<List<MFGraphRouteResult>> fetchGraphRoute(
  List<MFLocationComponent> locations, {
  MFTravelMode mode = MFTravelMode.car,
  MFRouteWeighting weighting = MFRouteWeighting.fastest,
  MFLanguageResult language = MFLanguageResult.vi,
  MFRouteRestriction? restriction,
}) async {
  final Map<String, Object> data = <String, Object>{
    'points': locationsToJson(locations),
    'mode': mode.index,
    'weighting': weighting.index,
    'language': language.index,
  };

  if (restriction != null) {
    data['restriction'] = restriction.toJson();
  }

  final response = await _ServicesChannel.invokeService('route#graph', data);
  validateResponse(response);

  return toListGraphRoute(response!['result']);
}