[Memory leak] Remove listener and dispose
This commit is contained in:
@@ -72,6 +72,7 @@ class _ScrollingFloatingButtonAnimatedState
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
super.initState();
|
||||||
_animationController = AnimationController(
|
_animationController = AnimationController(
|
||||||
vsync: this,
|
vsync: this,
|
||||||
duration: const Duration(milliseconds: 250),
|
duration: const Duration(milliseconds: 250),
|
||||||
@@ -80,22 +81,19 @@ class _ScrollingFloatingButtonAnimatedState
|
|||||||
lowerBound: 0,
|
lowerBound: 0,
|
||||||
upperBound: 120,
|
upperBound: 120,
|
||||||
);
|
);
|
||||||
super.initState();
|
widget.scrollController?.addListener(_scrollListener);
|
||||||
_handleScroll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
widget.scrollController!.removeListener(() {});
|
widget.scrollController?.removeListener(_scrollListener);
|
||||||
_animationController.dispose();
|
_animationController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Function to add listener for scroll
|
void _scrollListener() {
|
||||||
void _handleScroll() {
|
|
||||||
ScrollController scrollController = widget.scrollController!;
|
ScrollController scrollController = widget.scrollController!;
|
||||||
scrollController.addListener(() {
|
if (scrollController.position.pixels > widget.limitIndicator! &&
|
||||||
if (scrollController.position.pixels > widget.limitIndicator! &&
|
|
||||||
scrollController.position.userScrollDirection ==
|
scrollController.position.userScrollDirection ==
|
||||||
ScrollDirection.reverse) {
|
ScrollDirection.reverse) {
|
||||||
if (widget.animateIcon!) _animationController.forward();
|
if (widget.animateIcon!) _animationController.forward();
|
||||||
@@ -114,7 +112,6 @@ class _ScrollingFloatingButtonAnimatedState
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ class ThreadDetailController extends BaseController {
|
|||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
emailIdsPresentation.clear();
|
emailIdsPresentation.clear();
|
||||||
|
emailsInThreadDetailInfo.clear();
|
||||||
scrollController?.dispose();
|
scrollController?.dispose();
|
||||||
scrollController = null;
|
scrollController = null;
|
||||||
currentExpandedEmailId.value = null;
|
currentExpandedEmailId.value = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user