maplibre / flutter-maplibre-gl

Customizable, performant and vendor-free vector and raster maps, flutter wrapper for maplibre-native and maplibre-gl-js (fork of flutter-mapbox-gl/maps)
https://pub.dev/packages/maplibre_gl
Other
186 stars 106 forks source link

requestMyLocationLatLng() throws Type error #372

Open ivanesi opened 5 months ago

ivanesi commented 5 months ago

On iOS I got exception:

type 'Null' is not a subtype of type 'Map<dynamic, dynamic>'

when call controller.requestMyLocationLatLng():

#0      MethodChannelMaplibreGl.requestMyLocationLatLng (package:maplibre_gl_platform_interface/src/method_channel_maplibre_gl.dart:342:35)
<asynchronous suspension>

Future<void> onMapCreated(MaplibreMapController controller) async {
    try {
      final granted = await context.read<MapCubit>().requestLocationPermission();
      if (granted) {
        final latLng = await controller.requestMyLocationLatLng();
        _logger.trace(latLng);
      }
    } catch (e, st) {
      _logger.error(e, st);
    }
  }

On Android request freeze and no log output after it.

m0nac0 commented 5 months ago

Do you display the user's location on the map?

m0nac0 commented 5 months ago

Seems like we should also modify https://github.com/maplibre/flutter-maplibre-gl/blob/acb428a005efd9832a0a8e7ef0945f899dfb3ca5/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart#L342 by first checking if result != null && result is Map<dynamic, dynamic> and if that is not fulfilled, return null.