`style.addSource` throws a `PlatformException` but `style.getSource` does not return the existing source
I have
late final Source? source;
try {
source = await style.getSource(
'sourceId',
);
} catch (_) {
source = null;
}
Which returns a null on the ID sourceId. However when I try to add the source using the same ID sourceId
final geoJsonFeatureCollection = ...
final newSource = GeoJsonSource(
id: 'sourceId',
data: json.encode(
geoJsonFeatureCollection,
),
);
await style.addSource(
newSource,
);
I get a PlatformException(0, Source sourceId already exists, null, null)
I can't seem to get why this may be happening. Any pointers will be highly appreciated
PS: I am currently using version 2.3.0 of this library
I have modified my code to use a try {...} catch(...) {...} block at the point where the PlatformException is thrown. I now have
try {
await style.addSource(
newSource,
);
} catch (_) {
await style.removeStyleSource(
'sourceId',
);
await style.addSource(
newSource,
);
}
However the line
await style.removeStyleSource(
'sourceId',
);
throws a PlatformException(0, Source sourceId is not in style, null, null)
But if sourceId is not in style why is
await style.addSource(
newSource,
);
throwing a PlatformException(0, Source sourceId already exists, null, null) in the first place. These are 2 contradictory error messages. I have no idea what is happening here
I just upgraded to the latest version of this library as of now, Tuesday January 21st 2025 which is version 2.5.1. I am still experiencing this problem. I have also verified that this issue is happening on both Android and iOS