Dammyololade / flutter_polyline_points

A flutter plugin that's decodes encoded google poly line string into list of geo-coordinates suitable for showing route/polyline on maps
MIT License
105 stars 130 forks source link

Break change on 2.0.1 version #101

Closed FroJhoDev closed 2 months ago

FroJhoDev commented 2 months ago

In version 2.0.1, a break change was inserted, where the getRouteBetweenCoordinates function was previously used as follows.

Future<PolylineResult> getRouteBetweenCoordinates(
      String googleApiKey, PointLatLng origin, PointLatLng destination,
      {TravelMode travelMode = TravelMode.driving,
      List<PolylineWayPoint> wayPoints = const [],
      bool avoidHighways = false,
      bool avoidTolls = false,
      bool avoidFerries = true,
      bool optimizeWaypoints = false}) async {
    assert(googleApiKey.isNotEmpty, "Google API Key cannot be empty");
    try {
      var result = await NetworkUtil().getRouteBetweenCoordinates(
          request: PolylineRequest(
              apiKey: googleApiKey,
              origin: origin,
              destination: destination,
              mode: travelMode,
              wayPoints: wayPoints,
              avoidHighways: avoidHighways,
              avoidTolls: avoidTolls,
              avoidFerries: avoidFerries,
              alternatives: false,
              optimizeWaypoints: optimizeWaypoints));
      return result.isNotEmpty
          ? result[0]
          : PolylineResult(errorMessage: "No result found");
    } catch (e) {
      rethrow;
    }
  }

Now it must be carried out as follows.

Future<PolylineResult> getRouteBetweenCoordinates(
      {required PolylineRequest request, String? googleApiKey}) async {
    assert(
        (request.proxy == null &&
                googleApiKey != null &&
                googleApiKey.isNotEmpty) ||
            (request.proxy != null && googleApiKey == null),
        "Google API Key cannot be empty if proxy isn't provided");
    try {
      var result = await NetworkUtil().getRouteBetweenCoordinates(
          request: request, googleApiKey: googleApiKey);
      return result.isNotEmpty
          ? result[0]
          : PolylineResult(errorMessage: "No result found");
    } catch (e) {
      rethrow;
    }
  }

Modifying this function directly influences the use of the package, and if the flutter pub upgrade command is used, the package will be updated, causing implementation problems. This broken change is not documented in the README and it is also not possible to identify it through the version, something like 2.1.0, instead of 2.0.1 which does not indicate a change of this type.

Dammyololade commented 2 months ago

I'm so sorry, that was an oversight on my part. I've retracted the version. I would release another version 2.1.0 with information about the breaking changes