Skip to content

[google_maps_flutter] Raise MapUsedAfterWidgetDisposedError when map controller used after map disposed #9242

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

filiph
Copy link
Contributor

@filiph filiph commented May 12, 2025

This change introduces a new MapUsedAfterWidgetDisposedError that facilitates debugging when the user calls a method on GoogleMapsController after the associated map has been disposed. This replaces the previous behavior, which would sometimes throw a Platform-side error (MissingPluginException, Unable to establish connection on channel, etc.).

Although technically non-breaking (we're replacing one error with another), this could be disruptive because the new error is raised eagerly and synchronously, as soon as a call is made. Before, the call could have potentially succeeded (?), and the error was asynchronous (and so, potentially, unawaited and ignored?).

Fixes flutter/flutter#43785.

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

@filiph
Copy link
Contributor Author

filiph commented May 12, 2025

I was just made aware of #9227, which seems to fix the other aspect of flutter/flutter#43785. Happy to wait with this one until after that one lands.

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

Successfully merging this pull request may close these issues.

[maps] MissingPluginException when calling methods on maps instance that has been torn down on the native side
1 participant