Skip to content

[google_maps_flutter_web] Stop listening to map events when disposed #9250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JamesMcIntosh
Copy link
Contributor

@JamesMcIntosh JamesMcIntosh commented May 14, 2025

Fixes flutter/flutter#168782

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

@JamesMcIntosh JamesMcIntosh force-pushed the GITHUB-RES-1605-flutter-google-maps-web branch from 7ae7f9f to ecc91ce Compare May 14, 2025 02:55
@stuartmorgan-g stuartmorgan-g added the triage-web Should be looked at in web triage label Jun 3, 2025
@mdebbar mdebbar self-requested a review June 16, 2025 15:31
_streamController.add(
MapTapEvent(_mapId, gmLatLngToLatLng(event.latLng!)),
);
if (!_streamController.isClosed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this if (!_streamController.isClosed) check here and below.

The _onClickSubscription will be canceled as soon as the maps controller is disposed. That means the listener will not be called, so there's no need to do this check.

The only exception is map.onTilesloaded.first since that's a future and can't be "canceled".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[google_maps_flutter_web] Bad state: Cannot add new events after calling close
4 participants