Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
201be6bd
Unverified
Commit
201be6bd
authored
Jul 26, 2022
by
Dan Field
Committed by
GitHub
Jul 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update docs on ChangeNotifier.dispose and KeepAliveHandle.release (#108384)
parent
f1ebd288
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
change_notifier.dart
packages/flutter/lib/src/foundation/change_notifier.dart
+4
-0
automatic_keep_alive.dart
packages/flutter/lib/src/widgets/automatic_keep_alive.dart
+13
-1
No files found.
packages/flutter/lib/src/foundation/change_notifier.dart
View file @
201be6bd
...
@@ -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
));
...
...
packages/flutter/lib/src/widgets/automatic_keep_alive.dart
View file @
201be6bd
...
@@ -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
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment