fixed widget mounting errors

This commit is contained in:
2026-07-28 12:51:39 +02:00
parent 32be67426c
commit 7e9cbcf1e9
2 changed files with 31 additions and 22 deletions
+9 -5
View File
@@ -230,11 +230,15 @@ class _UserAvatarState extends State<UserAvatar> {
final pending = _pendingAvatars.putIfAbsent(url, () {
final future = _fetch(url);
future.whenComplete(() {
if (identical(_pendingAvatars[url], future)) {
_pendingAvatars.remove(url);
}
});
// Cleanup hangs off an error-neutralised copy: whenComplete on `future`
// itself returns a second future that forwards the error unawaited.
unawaited(
future.then<void>((_) {}, onError: (_) {}).whenComplete(() {
if (identical(_pendingAvatars[url], future)) {
_pendingAvatars.remove(url);
}
}),
);
return future;
});