mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #3001 from abarth/moar_error
Improve setState-after-dispose error message
This commit is contained in:
commit
8f28864b2d
@ -59,8 +59,8 @@ class TextStyle {
|
||||
/// The height of this text span, as a multiple of the font size.
|
||||
///
|
||||
/// If applied to the root [TextSpan], this value sets the line height, which
|
||||
/// is the minimum distance between each text baselines, as multiple of the
|
||||
/// font size.
|
||||
/// is the minimum distance between subsequent text baselines, as multiple of
|
||||
/// the font size.
|
||||
final double height;
|
||||
|
||||
/// The decorations to paint near the text (e.g., an underline).
|
||||
|
||||
@ -394,13 +394,19 @@ abstract class State<T extends StatefulWidget> {
|
||||
if (_debugLifecycleState == _StateLifecycle.defunct) {
|
||||
throw new FlutterError(
|
||||
'setState() called after dispose(): $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.'
|
||||
'This error happens if you call setState() on State object for a widget that '
|
||||
'no longer appears in the widget tree (e.g., whose parent widget no longer '
|
||||
'includes the widget in its build). This error can occur when code calls '
|
||||
'setState() from a timer or an animation callback. The preferred solution is '
|
||||
'to cancel the timer or stop listening to the animation in the dispose() '
|
||||
'callback. Another solution is to check the "mounted" property of this '
|
||||
'object before calling setState() to ensure the object is still in the '
|
||||
'tree.\n'
|
||||
'\n'
|
||||
'This error might indicate a memory leak if setState() is being called '
|
||||
'because another object is retaining a reference to this State object '
|
||||
'after it has been removed from the tree. To avoid memory leaks, '
|
||||
'consider breaking the reference to this object during dipose().'
|
||||
);
|
||||
}
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user