runWithSpinner<T> function
Runs fn while showing a spinner with message. Returns the result of fn.
Implementation
Future<T> runWithSpinner<T>(String message, Future<T> Function() fn) async {
final spinner = Spinner(message);
spinner.start();
try {
final result = await fn();
spinner.stop(success: true);
return result;
} catch (e) {
spinner.stop(success: false);
rethrow;
}
}