withLoading<T> method

Future<T> withLoading<T>(
  1. Future<T> action(), {
  2. String? msg,
  3. bool dismissOnTouch = false,
  4. bool dismissOnBackPressed = false,
})

Implementation

Future<T> withLoading<T>(Future<T> Function() action, {String? msg ,bool dismissOnTouch = false,
  bool dismissOnBackPressed = false}) async{
  try{
    DialogUtil.showLoading(msg: msg, dismissOnTouch: dismissOnTouch, dismissOnBackPressed: dismissOnBackPressed);
    return await action();
  }finally{
    await DialogUtil.dismissLoading();
  }
}