handleAction method
Perform a future action, catching any exceptions which may occur.
This also sets a isBusy
flag while the action is being performed.
Implementation
Future<void> handleAction(
Future<void> Function() function, {
Function(dynamic error)? onError,
String message = '',
bool skipBusyState = false,
}) async {
currentException = null;
if (!skipBusyState) {
isBusy = true;
}
try {
await function();
} catch (ex) {
if (onError != null) {
onError(ex);
}
currentException = ex;
rethrow;
} finally {
if (!skipBusyState) {
isBusy = false;
}
}
}