showCustomAlert method

void showCustomAlert({
  1. required Widget? body,
  2. Function? onComplete,
  3. bool cancelable = false,
  4. double? cornerRadius,
  5. double paddingScreen = 15,
  6. double? fixedSize,
})

Implementation

void showCustomAlert({
  required Widget? body,
  Function? onComplete,
  bool cancelable = false,
  double? cornerRadius,
  double paddingScreen = 15,
  double? fixedSize,
}) {
  hideAlert();
  isOpened = true;

  showDialog(
    barrierDismissible: cancelable,
    context: _context,
    builder: (BuildContext context) {
      return PopScope(
        canPop: cancelable,
        child: Dialog(
          insetPadding: EdgeInsets.all(AwesomeAlertTheme().defaultPaddingAlert ?? paddingScreen),
          backgroundColor: Colors.white,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(cornerRadius ?? AwesomeAlertTheme().borderRadius)),
          ),
          child: ConstrainedBox(
            constraints: (fixedSize != null || AwesomeAlertTheme().fixedSize != null)
                ? BoxConstraints(maxWidth: fixedSize ?? AwesomeAlertTheme().fixedSize ?? 700)
                : BoxConstraints(),
            child: Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(cornerRadius ?? AwesomeAlertTheme().borderRadius)),
              ),
              child: body,
            ),
          ),
        ),
      );
    },
  ).whenComplete(() {
    isOpened = false;
    if (onComplete != null) onComplete();
  });
}