Skip to content

Conversation

@HansMuller
Copy link
Contributor

@HansMuller HansMuller commented Feb 7, 2017

Added documentation to remind developers to do the same.

Fixes #7896
Fixes #7895

Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to unhook if _route is non-null before calling ModalRoute.of

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. In this case _route might be null before or after the ModalRoute.of(context) line. Similarly, _route could be null at dispose time.

void dependenciesChanged() {
  super.dependenciesChanged();
  _route?.removeScopedWillPopCallback(askTheUserIfTheyAreSure);
  _route = ModalRoute.of(context);
  _route?.addScopedWillPopCallback(askTheUserIfTheyAreSure);
}

@Hixie
Copy link
Contributor

Hixie commented Feb 7, 2017

LGTM

@HansMuller HansMuller force-pushed the will_pop_callback_disposal branch from 07d2e6a to 4dbe936 Compare February 7, 2017 22:30
@HansMuller HansMuller merged commit c08bac8 into flutter:master Feb 7, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

addScopedWillPopCallback docs don't mention unregistering FormState leaks registrations to route.addScopedWillPopCallback

3 participants