Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak open close quickly 93 #133

Merged
merged 5 commits into from
Sep 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Memory leak when opening and closing screen or dialog quickly #93
  • Loading branch information
pycstitch committed Sep 4, 2020
commit 14a1c1c5ec4919537cc80ba7e73b508235b2d60a
32 changes: 21 additions & 11 deletions lib/src/chat_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class DashChatState extends State<DashChat> {
bool showLoadMore = false;
String get messageInput => _text;
bool _initialLoad = true;
Timer _timer;

void onTextChange(String text) {
if (visible) {
Expand Down Expand Up @@ -407,24 +408,33 @@ class DashChatState extends State<DashChat> {
super.initState();
}

@override
void dispose() {
_timer?.cancel();
super.dispose();
}

void widgetBuilt(Duration d) {
double initPos = widget.inverted
? 0.0
: scrollController.position.maxScrollExtent + 25.0;

scrollController
.animateTo(
initPos,
duration: const Duration(milliseconds: 150),
curve: Curves.easeInOut,
)
.whenComplete(() => {
Timer(Duration(milliseconds: 1000), () {
setState(() {
_initialLoad = false;
});
})
});
initPos,
duration: const Duration(milliseconds: 150),
curve: Curves.easeInOut,
)
.whenComplete(() {
_timer?.cancel();
_timer = Timer(Duration(milliseconds: 1000), () {
if (this.mounted) {
setState(() {
_initialLoad = false;
});
}
});
});

scrollController.addListener(() {
bool topReached = widget.inverted
Expand Down