From 265f72bcf3b7bd5a4f5d9203da349290647167f8 Mon Sep 17 00:00:00 2001 From: Jaap Aarts Date: Sat, 17 Aug 2024 12:46:59 +0200 Subject: [PATCH] Don't reload the profile when the profile has been closed (#510) --- lib/ui/screens/profile_screen.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/ui/screens/profile_screen.dart b/lib/ui/screens/profile_screen.dart index 70f3fa174..29f58d3b2 100644 --- a/lib/ui/screens/profile_screen.dart +++ b/lib/ui/screens/profile_screen.dart @@ -621,7 +621,11 @@ class _AvatarViewDialogState extends State { // want to allow the user to update multiple // fields. As long as that isn't the case, we // also need to reload the MemberCubit below. - await widget.memberCubit.load(widget.member.pk); + if (!widget.memberCubit.isClosed) { + // It is possible the widget has been disposed, closing the memberCubit. + // Hence we only do this if it is not already closed. + await widget.memberCubit.load(widget.member.pk); + } messenger.hideCurrentSnackBar(); } on ApiException { messenger.hideCurrentSnackBar(); @@ -668,7 +672,11 @@ class _AvatarViewDialogState extends State { // want to allow the user to update multiple // fields. As long as that isn't the case, we // also need to reload the MemberCubit below. - await widget.memberCubit.load(widget.member.pk); + if (!widget.memberCubit.isClosed) { + // It is possible the widget has been disposed, closing the memberCubit. + // Hence we only do this if it is not already closed. + await widget.memberCubit.load(widget.member.pk); + } messenger.hideCurrentSnackBar(); } on ApiException { messenger.hideCurrentSnackBar();