fixed widget mounting errors
This commit is contained in:
@@ -173,7 +173,12 @@ class _AbsenceReportViewState extends State<AbsenceReportView> {
|
||||
icon: Icons.error_outline,
|
||||
text: errorToUserMessage(snapshot.error),
|
||||
button: ElevatedButton.icon(
|
||||
onPressed: () => setState(() => _init = _load()),
|
||||
onPressed: () {
|
||||
final reload = _load();
|
||||
setState(() {
|
||||
_init = reload;
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text('Erneut versuchen'),
|
||||
),
|
||||
|
||||
@@ -230,11 +230,15 @@ class _UserAvatarState extends State<UserAvatar> {
|
||||
|
||||
final pending = _pendingAvatars.putIfAbsent(url, () {
|
||||
final future = _fetch(url);
|
||||
future.whenComplete(() {
|
||||
// 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;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user