getRoad method Null safety

Future<Road> getRoad(
  1. {required List<LngLat> waypoints,
  2. RoadType roadType =,
  3. bool alternative = false,
  4. bool steps = true,
  5. Overview overview = Overview.full,
  6. Geometries geometries = Geometries.geojson,
  7. String languageCode = "en"}


this method make http call to get road from specific server this method return Road that contain road information like distance and duration and instruction or return Road with empty values.

return Road object that contain information of road that will help to draw road in the map or show important information to the user you should take a specific case when road object will contain empty values like 0.0 or empty string in case of any problem


Future<Road> getRoad({
  required List<LngLat> waypoints,
  RoadType roadType =,
  bool alternative = false,
  bool steps = true,
  Overview overview = Overview.full,
  Geometries geometries = Geometries.geojson,
  String languageCode = "en",
}) async {
  String path = generatePath(
    steps: steps,
    overview: overview,
    geometries: geometries,
  path += "&alternatives=$alternative";

  final response = await dio.get(path);
  if (response.statusCode == 200) {
    final Map<String, dynamic> responseJson =;
    return compute(
        jsonRoad: responseJson,
        langCode: languageCode,
        alternative: alternative,
  } else {
    return Road.withError();