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
67145aab
Commit
67145aab
authored
Feb 08, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide a better error for setState on a defunct State
Fixes #1695
parent
2cb534dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+15
-1
No files found.
packages/flutter/lib/src/widgets/framework.dart
View file @
67145aab
...
...
@@ -334,7 +334,21 @@ abstract class State<T extends StatefulComponent> {
/// component will not be scheduled for rebuilding, meaning that its rendering
/// will not be updated.
void
setState
(
VoidCallback
fn
)
{
assert
(
_debugLifecycleState
!=
_StateLifecycle
.
defunct
);
assert
(()
{
if
(
_debugLifecycleState
==
_StateLifecycle
.
defunct
)
{
throw
new
WidgetError
(
'setState() called after dipose():
$this
\n
'
'This error happens if you call setState() on State object for a widget that
\n
'
'no longer appears in the widget tree (e.g., whose parent widget no longer
\n
'
'includes the widget in its build). This error can occur when code calls
\n
'
'setState() from a timer or an animation callback. The preferred solution is
\n
'
'to cancel the timer or stop listening to the animation in the dispose()
\n
'
'callback. Another solution is to check the "mounted" property of this
\n
'
'object before calling setState() to ensure the object is still in the tree.'
);
}
return
true
;
});
fn
();
_element
.
markNeedsBuild
();
}
...
...
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