Open jaumard opened 3 months ago
I am also experiencing this same issue, i can work around by replacing the turf classes with the mapbox turf_adapter classes, but it's kind of annoying to do that.
final class Point extends turf.Point {
Point({super.bbox, required super.coordinates});
factory Point.fromJson(Map<String, dynamic> json) {
final turfPoint = turf.Point.fromJson(json);
return Point(bbox: turfPoint.bbox, coordinates: turfPoint.coordinates);
}
static Point decode(Object result) {
result as List<Object?>;
return Point.fromJson((result.first as Map).cast<String, dynamic>());
}
Object encode() {
return [toJson()];
}
}
Looking at the definition, i don't think the creation of our own Point is really necessary, since all you do is add static methods and factoy constructors and the encode
function, for which we could just make use of the dart extension feature. I understand that dart does not allow us to create static and factory methods using this feature, but I think given the upside of compatibllity with the turf library and existing codebases, it would be better to just create a Helper/Utility classes for those.
For now i guess its enough to just replace all turf imports with the mapbox flutter import
I have migrated from v1 to v2 and now I have class mismatch errors all over the place.
Look like Mapbox sdk is having it's own Point class that extends turf Point. Which is fine I guess.
But the issue is that if I use
FeatureCollection.fromJson(jsonDecode(data) as Map<String, dynamic>);
as FeatureCollection is not a class from Mapbox but from (geotype but let's say turf) then when I try to to pass this featureCollection back to Mapbox is fails with the following error:v2 is currently not usable to me.