Merge pull request #831 from abarth/track_mimic

Properly track mimics that move in the tree
This commit is contained in:
Adam Barth 2015-08-25 15:36:59 -07:00
commit 7f0f22abe9

View File

@ -75,10 +75,7 @@ class Mimic extends GlobalKeyWatcher {
void didUnmount() { void didUnmount() {
super.didUnmount(); super.didUnmount();
if (_mimicable != null) { _stopMimic();
_mimicable.stopMimic();
_mimicable = null;
}
} }
void didSyncWatchedKey(GlobalKey key, Widget widget) { void didSyncWatchedKey(GlobalKey key, Widget widget) {
@ -91,9 +88,18 @@ class Mimic extends GlobalKeyWatcher {
_setMimicable(null); _setMimicable(null);
} }
void _stopMimic() {
if (_mimicable != null) {
_mimicable.stopMimic();
_mimicable = null;
}
}
void _setMimicable(widget) { void _setMimicable(widget) {
if (_mimicable == null && widget != null) if (_mimicable != widget) {
_stopMimic();
widget.startMimic(); widget.startMimic();
}
setState(() { setState(() {
_mimicable = widget; _mimicable = widget;
}); });