flutter-maplibre-gl icon indicating copy to clipboard operation
flutter-maplibre-gl copied to clipboard

`animateCamera` appears to be broken on web

Open erik opened this issue 3 years ago • 0 comments

Hi, I noticed that calls to animateCamera() seemed to have no effect when running web builds, but the same call worked fine on iOS.

Here's what I was calling:

    mapController.animateCamera(CameraUpdate.newLatLng(coordinates));

After some debugging I traced it back to this change, which appears to have triggered a null dereference: https://github.com/m0nac0/flutter-maplibre-gl/commit/c3e941b03b574880eead1db87e360d74c7a1e1c8#diff-4666b03e54f2025da49b0f804d0eb4401b13c0e9599cf74089d5d6a4abf144d0

Specifically, the use of .jsObject appears to be in the wrong place, as getProperty returns a null for unspecified options.

I put together a quick fix in a fork, but I do wonder if this is really the right approach. Maybe the CameraOptions class should be updated to reflect the nullability of its members instead.

For now I'm just using my fork as a dependency override, but if you think it's the right fix I can open a PR.

erik avatar Oct 06 '22 08:10 erik