Remove controllerListener on dispose
This commit is contained in:
parent
4d7cf69126
commit
114dc3dd50
|
@ -106,36 +106,8 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
|
|
||||||
_dragHeight = heightNotifier.value;
|
_dragHeight = heightNotifier.value;
|
||||||
|
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null)
|
||||||
widget.controller.addListener(() {
|
widget.controller.addListener(controllerListener);
|
||||||
switch (widget.controller.value.height) {
|
|
||||||
case -1:
|
|
||||||
_animateToHeight(
|
|
||||||
widget.minHeight,
|
|
||||||
duration: widget.controller.value.duration,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case -2:
|
|
||||||
_animateToHeight(
|
|
||||||
widget.maxHeight,
|
|
||||||
duration: widget.controller.value.duration,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case -3:
|
|
||||||
_animateToHeight(
|
|
||||||
0,
|
|
||||||
duration: widget.controller.value.duration,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_animateToHeight(
|
|
||||||
widget.controller.value.height.toDouble(),
|
|
||||||
duration: widget.controller.value.duration,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
@ -144,6 +116,10 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_heightController.close();
|
_heightController.close();
|
||||||
_animationController.dispose();
|
_animationController.dispose();
|
||||||
|
|
||||||
|
if (widget.controller != null)
|
||||||
|
widget.controller.removeListener(controllerListener);
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,6 +325,35 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
animating = true;
|
animating = true;
|
||||||
_animationController.forward(from: 0);
|
_animationController.forward(from: 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void controllerListener() {
|
||||||
|
switch (widget.controller.value.height) {
|
||||||
|
case -1:
|
||||||
|
_animateToHeight(
|
||||||
|
widget.minHeight,
|
||||||
|
duration: widget.controller.value.duration,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case -2:
|
||||||
|
_animateToHeight(
|
||||||
|
widget.maxHeight,
|
||||||
|
duration: widget.controller.value.duration,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case -3:
|
||||||
|
_animateToHeight(
|
||||||
|
0,
|
||||||
|
duration: widget.controller.value.duration,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_animateToHeight(
|
||||||
|
widget.controller.value.height.toDouble(),
|
||||||
|
duration: widget.controller.value.duration,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///-1 Min, -2 Max, -3 Dismiss
|
///-1 Min, -2 Max, -3 Dismiss
|
||||||
|
|
Loading…
Reference in New Issue