withLoading method

Future<T> withLoading(
  1. BuildContext context, [
  2. String? message
])

Implementation

Future<T> withLoading(BuildContext context, [String? message]) {
  LoadingHelper.show(context, message);
  return then((value) {
    Future.delayed(const Duration(milliseconds: 1000), LoadingHelper.hide);
    return value;
  }).catchError((error) {
    Future.delayed(const Duration(milliseconds: 1000), LoadingHelper.hide);
    throw error;
  });
}