simplified code across the app and consolidated duplicated helpers

This commit is contained in:
2026-09-27 17:29:54 +02:00
parent 3e856d0b1c
commit ee1240f71a
155 changed files with 1772 additions and 2546 deletions
@@ -8,6 +8,11 @@ typedef AsyncErrorBuilder = String Function(Object error);
TextStyle _asyncErrorTextStyle(BuildContext context) =>
TextStyle(color: Theme.of(context).colorScheme.error, fontSize: 13);
Widget _leadingLabel(Widget leading, Widget label) => Row(
mainAxisSize: MainAxisSize.min,
children: [leading, const SizedBox(width: 8), label],
);
/// Wraps [action] with a try/catch that pops up an [InfoDialog] on failure
/// (using [errorBuilder] or the default error mapper). Returns `true` on
/// success, `false` on caught failure.
@@ -23,14 +28,7 @@ Future<bool> runWithErrorDialog(
} catch (e) {
Haptics.error();
if (!context.mounted) return false;
final message = errorBuilder != null
? errorBuilder(e)
: errorToUserMessage(e);
final details = errorToTechnicalDetails(e);
final body = details != null && details != message
? '$message\n\n$details'
: message;
InfoDialog.show(context, body, copyable: true, title: 'Fehler');
InfoDialog.showError(context, e, message: errorBuilder?.call(e));
return false;
}
}
@@ -55,14 +53,13 @@ class AsyncActionController extends ChangeNotifier {
notifyListeners();
try {
await action();
_busy = false;
notifyListeners();
return true;
} catch (e) {
_busy = false;
_error = errorBuilder != null ? errorBuilder(e) : errorToUserMessage(e);
notifyListeners();
return false;
} finally {
_busy = false;
notifyListeners();
}
}