Why am I getting a null check error when using AnimatedLocationMarkerLayer on flutter_map?

38 views Asked by At

I'm trying to show other users on the map by using a StreamBuilder and the animatedLocationMarkerLayer from flutter_map_location_marker https://pub.dev/packages/flutter_map_location_marker

Here is the relevant code:

databaseHandler.locationMarkerStream.listen((LocationMarkerPosition locationMarkerPosition) {
        print('Received location marker: $locationMarkerPosition');
        //Create AnimatedLocationMarkerLayer for each user
        final animatedLocationMarkerLayer = AnimatedLocationMarkerLayer(
          position: locationMarkerPosition,
        );
        setState(() {
          locationMarkerLayers.add(animatedLocationMarkerLayer);
        });
    });

This is the console output:

I/flutter (24103): Received location marker: LocationMarkerPosition(latitude: -32.04927, longitude: 115.84554, accuracy: 1.0)

════════ Exception caught by widgets library ═══════════════════════════════════
The following _TypeError was thrown building LocationMarkerLayer(position: LocationMarkerPosition(latitude: -35.04784, longitude: 118.84782, accuracy: 1.0), heading: LocationMarkerHeading(heading: 1.0, accuracy: 1.0), style: Instance of 'LocationMarkerStyle', dirty):
Null check operator used on a null value

Anyone have any ideas? At first I thought it was because I didn't provide a heading value, but even when I filled out the rest of the constructor with my own default values I get the same error. The only thing I didn't try adding was a key. The error itself doesn't seem to indicate that any of the values are null, it's correctly displaying the latitude and longitude etc.

Thanks in advance!

0

There are 0 answers