showDialogWithCloseIcon<T> function

Future<T?> showDialogWithCloseIcon<T>({
  1. required BuildContext context,
  2. required Widget title,
  3. required Widget content,
  4. Widget? closeIcon,
  5. VoidCallback? onTapCloseIcon,
  6. EdgeInsets? insetPadding,
  7. bool barrierDismissible = true,
  8. bool useRootNavigator = true,
  9. FlutterTagPosition? closeButtonPosition,
  10. FlutterTagAnimation? closeButtonAnimation,
  11. FlutterTagStyle? closeButtonStyle,
  12. Color? backgroundColor,
  13. Color? dialogColor,
  14. SharpRectangleBorder? shape,
})

Implementation

Future<T?> showDialogWithCloseIcon<T>({
  required BuildContext context,

  ///title Button
  required Widget title,

  ///content Button
  required Widget content,

  ///Close Button
  Widget? closeIcon,
  VoidCallback? onTapCloseIcon,
  EdgeInsets? insetPadding,
  bool barrierDismissible = true,
  bool useRootNavigator = true,
  FlutterTagPosition? closeButtonPosition,
  FlutterTagAnimation? closeButtonAnimation,
  FlutterTagStyle? closeButtonStyle,
  Color? backgroundColor,
  Color? dialogColor,
  SharpRectangleBorder? shape,
}) async {
  return showDialog<T>(
    context: context,
    useRootNavigator: useRootNavigator,
    barrierDismissible: barrierDismissible,
    barrierColor: backgroundColor,
    builder: (BuildContext ctx) {
      return AlertDialog(
        backgroundColor: Colors.transparent,
        insetPadding: EdgeInsets.zero,
        contentPadding: EdgeInsets.zero,
        content: FlutterTag(
          tagStyle: closeButtonStyle ??
              const FlutterTagStyle(
                  tagColor: Colors.red, shape: FlutterTagShape.circle),
          stackFit: StackFit.passthrough,
          position: closeButtonPosition ?? FlutterTagPosition.topStart(),
          tagAnimation: closeButtonAnimation ??
              const FlutterTagAnimation.rotation(toAnimate: false),
          onTap: () {
            if (onTapCloseIcon != null) {
              onTapCloseIcon.call();
            } else {
              Navigator.of(context).pop();
            }
          },
          tagContent: closeIcon ??
              const Icon(
                Icons.close,
                color: Colors.white,
              ),
          child: Card(
            shape: shape,
            borderOnForeground: false,
            color: dialogColor,
            child: Padding(
              padding: insetPadding ?? const EdgeInsets.all(16),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  title,
                  20.maxSpace,
                  content,
                ],
              ),
            ),
          ),
        ),
      );
    },
  );
}