Animate search icon only if the view is still mounted

This commit is contained in:
Vishnu Mohandas 2020-05-02 02:22:24 +05:30
parent 2e482f6815
commit 7783fabdb9

View file

@ -156,9 +156,9 @@ class _AnimatedSearchIconWidgetState extends State<AnimatedSearchIconWidget>
AnimationController(duration: const Duration(seconds: 1), vsync: this);
_animation = Tween<double>(begin: 100, end: 200).animate(_controller)
..addListener(() {
setState(() {
// The state that has changed here is the animation objects value.
});
if (mounted) {
setState(() {});
}
})
..addStatusListener((status) {
if (status == AnimationStatus.completed) {