-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Update docs on ChangeNotifier.dispose and KeepAliveHandle.release #108384
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM since documenting the current behavior is not making it worse. I think we can do better by improving the actual API, though.
@@ -321,6 +321,9 @@ class KeepAliveNotification extends Notification { | |||
class KeepAliveHandle extends ChangeNotifier { | |||
/// Trigger the listeners to indicate that the widget | |||
/// no longer needs to be kept alive. | |||
/// | |||
/// This method does not call [dispose]. When the handle is not needed | |||
/// anymore, it must be [dispose]d regardless of whether notifying listeners. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just fix this by deprecating release and overriding dispose
to call notifyListeners
before super.dispose
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that makes sense. I wasn't clear on what if anything that would break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to do that in this PR or should we file an issue/follow up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer doing it in this PR, but I would be fine either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ARgh, we should not be calling both release and dispose now though since that will notify listeners twice... |
@@ -354,7 +367,6 @@ mixin AutomaticKeepAliveClientMixin<T extends StatefulWidget> on State<T> { | |||
|
|||
void _releaseKeepAlive() { | |||
// Dispose and release do not imply each other. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well this comment definitely seems out of place now
See https://github.com/flutter/flutter/pull/108227/files#r930193822
@polina-c FYI