showLoading static method

void showLoading({
  1. String? msg,
  2. bool dismissOnTouch = true,
  3. bool dismissOnBackPressed = true,
})

Implementation

static void showLoading({String? msg, bool dismissOnTouch = true,
      bool dismissOnBackPressed = true}) async {
  if (_isShowLoading) return;
  _isShowLoading = true;
  await showDialog(context: Get.context!,
      barrierDismissible: dismissOnTouch,
      builder: (context) => PopScope(
          canPop: dismissOnBackPressed,
          child: Material(type: MaterialType.transparency,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  decoration: BoxDecoration(
                      color: Theme.of(context).dialogBackgroundColor,
                      borderRadius: BorderRadius.circular((10))),
                  padding: msg != null ? const EdgeInsets.symmetric(vertical: 25) : null,
                  width: msg != null ? 110 : 60,
                  height: msg != null ? null : 60,
                  alignment: Alignment.center,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(),),
                      if (msg != null)
                        Padding(padding: const EdgeInsets.only(top: 15, left: 10, right: 10),
                          child: Text(msg, style: TextStyle(color: Theme.of(Get.context!).textTheme.titleLarge!.color!,
                              fontSize: 13), textAlign: TextAlign.center, maxLines: 1,
                              overflow: TextOverflow.ellipsis,),)
                    ],
                  ),
                )
              ],
            ),
          )));
  _isShowLoading = false;
}