withLoading method
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;
});
}