dialog static method

dynamic dialog(
  1. BuildContext context, {
  2. String? title,
  3. Widget? icon,
  4. String? desc,
  5. bool twoButton = false,
  6. bool sButton1 = true,
  7. bool sButton2 = true,
  8. String? tButton1,
  9. String? tButton2,
  10. Function? onTap1,
  11. Function? onTap2,
})

Implementation

static dialog(BuildContext context,
    {String? title,
    Widget? icon,
    String? desc,
    bool twoButton = false,
    bool sButton1 = true,
    bool sButton2 = true,
    String? tButton1,
    String? tButton2,
    Function? onTap1,
    Function? onTap2}) {
  showFlash(
    context: context,
    persistent: true,
    transitionDuration: const Duration(milliseconds: 250),
    barrierBlur: 5,
    barrierColor: Colors.transparent,
    builder: (context, controller) {
      return Container(
        color: Colors.black.withOpacity(0.7),
        child: FadeTransition(
          opacity: controller.controller,
          child: AlertDialog(
              backgroundColor: Theme.of(context).cardColor,
              shape: const RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(8)),
                side: BorderSide(),
              ),
              contentPadding: EdgeInsets.all(Spaces.defaultMtSpace_60)
                  .copyWith(
                      top: Spaces.defaultMtSpace_30,
                      bottom: Spaces.defaultMtSpace_30),
              title: Center(
                  child: Column(
                children: [
                  icon ?? Container(),
                  Padding(
                    padding:
                        EdgeInsets.only(bottom: Spaces.defaultMtSpace_30),
                    child: Text(
                      title!,
                      style: const TextStyle(fontWeight: FontWeight.bold),
                    ).h4,
                  ),
                ],
              )),
              content: Text(
                desc!,
              ).h5,
              actions: twoButton
                  ? [
                      TextButton(
                        onPressed: () {
                          if (sButton1 == true) {
                            // await audioPlayer.play(Conf.defaultSoundDesktop, isLocal: true);
                            // var bytes = await (
                            //     await audioCache.load(Conf.defaultSound)).readAsBytes();
                            // audioCache.playBytes(bytes);
                          }
                          if (onTap1 != null) {
                            onTap1();
                          }
                          controller.dismiss();
                        },
                        child: Text(
                          tButton1 ?? '',
                        ).h6.pColor,
                      ),
                      TextButton(
                        onPressed: () async {
                          if (sButton2 == true) {
                            // await audioPlayer.play(Conf.defaultSoundDesktop, isLocal: true);
                            // var bytes = await (await audioCache.load(Conf.defaultSound)).readAsBytes();
                            // audioCache.playBytes(bytes);
                          }
                          if (onTap2 != null) {
                            onTap2();
                          }
                          controller.dismiss();
                        },
                        child: Text(
                          tButton2 ?? '',
                        ).h6.pColor,
                      ),
                    ]
                  : [
                      TextButton(
                        onPressed: () async {
                          controller.dismiss();
                        },
                        child: const Text(
                          'باشه',
                        ).h6.pColor,
                      ),
                    ]),
        ),
      );
    },
  );
}