umgc / fall2022

SWEN 670 Fall 2022 cohort
Creative Commons Zero v1.0 Universal
4 stars 3 forks source link

Fix issue when navigating between the notifications and mail view #660

Closed mdconatser closed 2 years ago

mdconatser commented 2 years ago

Great work on the Notifications view and navigating to the individual main items. I've been working on the individual mail view and was testing it with the notifications today. I also made a few small changes to the notifications view that I'll upload tomorrow

I noticed that if there were multiple messages that were related to the notification subscription and you clicked on them and went back to the notification screen. You would kick off an exception - setState() called after dispose(): MailPieceViewWidgetState#6caf0(lifecycle state: defunct, not mounted) This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.

The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().

Here is the stacktrace - #0      State.setState. (package:flutter/src/widgets/framework.dart:1078:9)#1      State.setState (package:flutter/src/widgets/framework.dart:1113:6)#2      MailPieceViewWidgetState._getImgFromEmail (package:summer2022/ui/mail_view_indv.dart:102:15)#3      MailPieceViewWidgetState._getMailPieceEmail (package:summer2022/ui/mail_view_indv.dart:61:5)

ntafese commented 2 years ago

I can't reproduce this issue in my environment.