fixed widget mounting errors
This commit is contained in:
@@ -165,23 +165,28 @@ class _AbsenceReportViewState extends State<AbsenceReportView> {
|
|||||||
Widget _buildBody(BuildContext context) => FutureBuilder<void>(
|
Widget _buildBody(BuildContext context) => FutureBuilder<void>(
|
||||||
future: _init,
|
future: _init,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState != ConnectionState.done) {
|
if (snapshot.connectionState != ConnectionState.done) {
|
||||||
return const Center(child: AppProgressIndicator.large());
|
return const Center(child: AppProgressIndicator.large());
|
||||||
}
|
}
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
return PlaceholderView(
|
return PlaceholderView(
|
||||||
icon: Icons.error_outline,
|
icon: Icons.error_outline,
|
||||||
text: errorToUserMessage(snapshot.error),
|
text: errorToUserMessage(snapshot.error),
|
||||||
button: ElevatedButton.icon(
|
button: ElevatedButton.icon(
|
||||||
onPressed: () => setState(() => _init = _load()),
|
onPressed: () {
|
||||||
icon: const Icon(Icons.refresh),
|
final reload = _load();
|
||||||
label: const Text('Erneut versuchen'),
|
setState(() {
|
||||||
),
|
_init = reload;
|
||||||
);
|
});
|
||||||
}
|
},
|
||||||
return _buildForm(context);
|
icon: const Icon(Icons.refresh),
|
||||||
},
|
label: const Text('Erneut versuchen'),
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _buildForm(context);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
Widget _buildForm(BuildContext context) {
|
Widget _buildForm(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|||||||
@@ -230,11 +230,15 @@ class _UserAvatarState extends State<UserAvatar> {
|
|||||||
|
|
||||||
final pending = _pendingAvatars.putIfAbsent(url, () {
|
final pending = _pendingAvatars.putIfAbsent(url, () {
|
||||||
final future = _fetch(url);
|
final future = _fetch(url);
|
||||||
future.whenComplete(() {
|
// Cleanup hangs off an error-neutralised copy: whenComplete on `future`
|
||||||
if (identical(_pendingAvatars[url], future)) {
|
// itself returns a second future that forwards the error unawaited.
|
||||||
_pendingAvatars.remove(url);
|
unawaited(
|
||||||
}
|
future.then<void>((_) {}, onError: (_) {}).whenComplete(() {
|
||||||
});
|
if (identical(_pendingAvatars[url], future)) {
|
||||||
|
_pendingAvatars.remove(url);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
return future;
|
return future;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user