Unverified Commit 201be6bd authored by Dan Field's avatar Dan Field Committed by GitHub

Update docs on ChangeNotifier.dispose and KeepAliveHandle.release (#108384)

parent f1ebd288
...@@ -297,6 +297,10 @@ class ChangeNotifier implements Listenable { ...@@ -297,6 +297,10 @@ class ChangeNotifier implements Listenable {
/// [addListener] will throw after the object is disposed). /// [addListener] will throw after the object is disposed).
/// ///
/// This method should only be called by the object's owner. /// This method should only be called by the object's owner.
///
/// This method does not notify listeners, and clears the listener list once
/// it is called. Consumers of this class must decide on whether to notify
/// listeners or not immediately before disposal.
@mustCallSuper @mustCallSuper
void dispose() { void dispose() {
assert(ChangeNotifier.debugAssertNotDisposed(this)); assert(ChangeNotifier.debugAssertNotDisposed(this));
......
...@@ -321,9 +321,22 @@ class KeepAliveNotification extends Notification { ...@@ -321,9 +321,22 @@ class KeepAliveNotification extends Notification {
class KeepAliveHandle extends ChangeNotifier { class KeepAliveHandle extends ChangeNotifier {
/// Trigger the listeners to indicate that the widget /// Trigger the listeners to indicate that the widget
/// no longer needs to be kept alive. /// 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.
@Deprecated(
'Use dispose instead. '
'This feature was deprecated after v3.3.0-0.0.pre.',
)
void release() { void release() {
notifyListeners(); notifyListeners();
} }
@override
void dispose() {
notifyListeners();
super.dispose();
}
} }
/// A mixin with convenience methods for clients of [AutomaticKeepAlive]. Used /// A mixin with convenience methods for clients of [AutomaticKeepAlive]. Used
...@@ -354,7 +367,6 @@ mixin AutomaticKeepAliveClientMixin<T extends StatefulWidget> on State<T> { ...@@ -354,7 +367,6 @@ mixin AutomaticKeepAliveClientMixin<T extends StatefulWidget> on State<T> {
void _releaseKeepAlive() { void _releaseKeepAlive() {
// Dispose and release do not imply each other. // Dispose and release do not imply each other.
_keepAliveHandle!.release();
_keepAliveHandle!.dispose(); _keepAliveHandle!.dispose();
_keepAliveHandle = null; _keepAliveHandle = null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment