mapbox / mapbox/mapbox-maps-flutter
`style.addSource` throws a `PlatformException` but `style.getSource` does not return the existing source
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 380
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior in the `style.getSource` and `style.addSource` calls using the reported `sourceId` and library version 2.3.0. Trace how each call handles existing sources and platform errors; done means the source lookup and add operation consistently reflect whether `sourceId` already exists, with a regression test if the repository provides a relevant test location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100