mapbox / mapbox/mapbox-maps-flutter
Fix issue Mapbox used after being disposed
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 380
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
I have a logout button in my app.
After logging out, an exception is being thrown which says: A MapboxMap was used after being disposed.
Once you have called dispose() on a MapboxMap, it can no longer be used.
Below are the relevant codes:
```
void _showLogoutConfirmationDialogUsing(
BuildContext context,
) =>
ActionDialog.show(
context,
content: context.localize.areYouSureYouWantToLogout,
onActionDismissed: () {
Navigator.of(
context,
).pop();
},
onActionConfirmed: () {
Navigator.of(
context,
).pop();
context.read().add(
const Web3AuthLogoutEvent.logout(),
);
},
);
```
```
@override
void dispose() {
_mapboxMap?.dispose();
_clickedRestriction.dispose();
_centerLocationNotifier.dispose();
_mapStyleNotifier.dispose();
super.dispose();
}
```
https://github.com/user-attachments/assets/b79c8405-ffd2-4216-a27f-681de923c213
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 with the provided logout callback and the widget's dispose() implementation, then reproduce the logout flow while tracing uses of _mapboxMap after disposal. Compare the timing of logout, widget disposal, and map operations; done means the reported "MapboxMap was used after being disposed" exception no longer occurs.
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