revert method

  1. @override
PolylineOp revert(
  1. List<InteractivePolyline<Object>> list
)
override

Reverts this operation from the current list.

Modifies current in place and returns the operation itself (or reversed op).

Implementation

@override
PolylineOp revert(List<InteractivePolyline> list) {
  final idx = list.indexWhere((p) => p.key == key);
  if (idx >= 0) {
    final target = list[idx];
    final deltaLat = from.latitude - to.latitude;
    final deltaLng = from.longitude - to.longitude;
    final newPoints = target.points.map((p) {
      return LatLng(p.latitude + deltaLat, p.longitude + deltaLng);
    }).toList();
    list[idx] = target.copyWith(points: newPoints);
  }
  return this;
}