messageDialog static method

dynamic messageDialog(
  1. BuildContext context,
  2. String title,
  3. String content, {
  4. bool isDismissible = true,
  5. bool isTitlerequired = true,
  6. dynamic onTap()?,
})

Implementation

static messageDialog(
  BuildContext context,
  String title,
  String content, {
  bool isDismissible = true,
  bool isTitlerequired = true,
  Function()? onTap,
}) {
  final Localization localization = Localization.getInstance();

  showDialog(
    barrierDismissible: isDismissible,
    context: context,
    builder: (_) {
      return PopScope(
          canPop: isDismissible,
          child: Dialog(
            insetPadding: EdgeInsets.symmetric(
                horizontal: SizeConstant.getHeightWithScreen(10),
                vertical: SizeConstant.getHeightWithScreen(24)),
            child: Container(
              decoration: BoxDecoration(
                color: ColorConstant.white,
                borderRadius: BorderRadius.circular(
                    SizeConstant.getHeightWithScreen(16)),
              ),
              padding: EdgeInsets.symmetric(
                  vertical: SizeConstant.getHeightWithScreen(30),
                  horizontal: SizeConstant.getHeightWithScreen(20)),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  SvgPicture.asset(
                    "assets/images/error_icon.svg",
                    package: Constants.packageName,
                    height: SizeConstant.getHeightWithScreen(50),
                    width: SizeConstant.getHeightWithScreen(50),
                  ),
                  SizedBox(
                    height: SizeConstant.getHeightWithScreen(10),
                  ),
                  isTitlerequired
                      ? Text(
                          title,
                          style: TextStyle(
                            color: ColorConstant.pgvDescTextColor,
                            fontSize: SizeConstant.mediumFont,
                            fontWeight: FontWeight.w600,
                          ),
                        )
                      : const SizedBox(),
                  isTitlerequired
                      ? SizedBox(
                          height: SizeConstant.getHeightWithScreen(6),
                        )
                      : const SizedBox(),
                  Text(
                    content,
                    style: TextStyle(
                        color: ColorConstant.grey11,
                        fontSize: SizeConstant.smallFont,
                        fontWeight: FontWeight.w500),
                  ),
                  SizedBox(
                    height: SizeConstant.getHeightWithScreen(10),
                  ),
                  Text.rich(
                    TextSpan(children: [
                      TextSpan(
                        text: UDID.traceId.isEmpty ? UDID.uDID : UDID.traceId,
                        style: TextStyle(
                            color: ColorConstant.grey11,
                            fontSize: SizeConstant.smallFont,
                            fontWeight: FontWeight.w500),
                      ),
                      WidgetSpan(
                        alignment: PlaceholderAlignment.middle,
                        child: Padding(
                          padding: EdgeInsets.only(
                            left: SizeConstant.getHeightWithScreen(4),
                          ),
                          child: GestureDetector(
                            onTap: () async {
                              await Clipboard.setData(
                                ClipboardData(
                                  text: UDID.traceId.isEmpty
                                      ? UDID.uDID
                                      : UDID.traceId,
                                ),
                              );
                              showAssetSnackbar(
                                UDID.traceId.isEmpty
                                    ? UDID.uDID
                                    : UDID.traceId,
                                "",
                              );
                            },
                            child: Container(
                              color: Colors.transparent,
                              padding: EdgeInsets.all(
                                SizeConstant.getHeightWithScreen(5),
                              ),
                              child: Icon(
                                Icons.copy,
                                size: SizeConstant.getHeightWithScreen(12),
                                color: ColorConstant.primaryColor,
                              ),
                            ),
                          ),
                        ),
                      ),
                    ]),
                  ),
                  SizedBox(
                    height: SizeConstant.getHeightWithScreen(22),
                  ),
                  InkWell(
                    onTap: () {
                      if (onTap == null) {
                        Get.close(1);
                      } else {
                        onTap();
                      }
                    },
                    child: Container(
                        width: SizeConstant.getHeightWithScreen(130),
                        height: SizeConstant.getHeightWithScreen(40),
                        decoration: BoxDecoration(
                          border: Border.all(
                            width: 1,
                            color: ColorConstant.forgotPasswordColor,
                          ),
                          borderRadius: BorderRadius.circular(
                              SizeConstant.getHeightWithScreen(10)),
                        ),
                        child: Center(
                          child: Text(
                            localization.translate('ok'),
                            style: TextStyle(
                              fontSize: SizeConstant.mediumFont,
                              fontWeight: FontWeight.w500,
                              color: ColorConstant.forgotPasswordColor,
                            ),
                          ),
                        )),
                  ),
                ],
              ),
            ),
          ));
    },
  );
}