getRoute method

  1. @override
Future<MPRoute> getRoute(
  1. MPPoint origin,
  2. MPPoint destination
)
override

Implementation

@override
Future<MPRoute> getRoute(MPPoint origin, MPPoint destination) async {
  Map<String, dynamic>? result = await directionsServiceMethodChannel
      .invokeMapMethod('DSE_getRoute', {
    'origin': origin._jsonEncode(),
    'destination': destination._jsonEncode()
  });

  final route = MPRoute.fromJson(result?["route"]);
  final error = MPError.fromJson(result?["error"]);

  if (route != null) {
    return Future.value(route);
  } else if (error != null) {
    return Future.error(error);
  } else {
    return Future.error(MPError(
        code: MPError.unknownError,
        message: "Did not receieve route object from Platform"));
  }
}