Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 4 commits into from
Jul 26, 2022

Conversation

dnfield
Copy link
Contributor

@dnfield dnfield commented Jul 26, 2022

@dnfield dnfield requested review from goderbauer and chunhtai July 26, 2022 18:52
@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 26, 2022
@dnfield dnfield added the d: api docs Issues with https://api.flutter.dev/ label Jul 26, 2022
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@goderbauer goderbauer left a 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.
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@dnfield
Copy link
Contributor Author

dnfield commented Jul 26, 2022

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.
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants