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