customAlertDialog function

dynamic customAlertDialog(
  1. BuildContext context,
  2. Widget title,
  3. Widget content, {
  4. Widget? titleIcon,
  5. String? positiveButtonText,
  6. Function? positiveButtonAction,
  7. String? negativeButtonText,
  8. Function? negativeButtonAction,
  9. String? neutralButtonText,
  10. Function? neutralButtonAction,
  11. bool hideNeutralButton = false,
  12. bool closeOnBackPress = false,
  13. bool confirmationDialog = false,
  14. String? confirmationMessage,
})

customAlertDialog function with title and content widgets

positiveButtonText for positive button text negativeButtonText for negative button text neutralButtonText for negative button text hideNeutralButton to hide the Neutral Button default is false closeOnBackPress to close dialog on back button default is false confirmationDialog to make the confirmation dialog default is false confirmationMessage confirmation message default is 'Please check this box for Confirmation!'

Implementation

customAlertDialog(
  BuildContext context,
  Widget title,
  Widget content, {
  Widget? titleIcon,
  String? positiveButtonText,
  Function? positiveButtonAction,
  String? negativeButtonText,
  Function? negativeButtonAction,
  String? neutralButtonText,
  Function? neutralButtonAction,
  bool hideNeutralButton = false,
  bool closeOnBackPress = false,
  bool confirmationDialog = false,
  String? confirmationMessage,
}) {
  return showGeneralDialog(
    context: context,
    barrierDismissible: closeOnBackPress,
    barrierLabel: "",
    barrierColor: getBarrierColor(),
    transitionDuration: getDialogPopUpAnimationDuration(),
    transitionBuilder: (c2, a1, a2, widget) {
      return getDialogAnimation(a1, a2, widget);
    },
    pageBuilder: (c1, a1, a2) => WillPopScope(
      child: SimpleAlertDialog(
        title,
        content,
        icon: titleIcon,
        negativeButtonText: negativeButtonText,
        negativeButtonAction: negativeButtonAction,
        positiveButtonText: positiveButtonText,
        positiveButtonAction: positiveButtonAction,
        neutralButtonText: neutralButtonText,
        neutralButtonAction: neutralButtonAction,
        hideNeutralButton: hideNeutralButton,
        confirmationDialog: confirmationDialog,
        confirmationMessage: confirmationMessage,
      ),
      onWillPop: () async => closeOnBackPress,
    ),
  );
}