yShowBuilder function

void yShowBuilder(
  1. String message,
  2. dynamic confirmCallBack(),
  3. dynamic cancelCallBack()?,
  4. bool cancelAble, {
  5. String posTitle = "确定",
  6. String negTitle = "取消",
  7. BuildContext? context,
})

弹出对话框

Implementation

void yShowBuilder(String message, Function() confirmCallBack, Function()? cancelCallBack, bool cancelAble, {String posTitle = "确定", String negTitle = "取消", BuildContext? context}) async {
  showDialog(
    context: context ?? yPages.last.context,
    barrierDismissible: false,
    builder: (context) {
      return WillPopScope(
        onWillPop: () => Future.value(false),
        child: AlertDialog(
          title: Text("${YConfig.appName}提示", style: const TextStyle(color: Colors.black)),
          content: SingleChildScrollView(child: Text(message, style: const TextStyle(color: Colors.black))),
          actions: [
            _YFlatButton(Text(posTitle, style: const TextStyle(color: Colors.black)), onClick: () {
              confirmCallBack();
              Navigator.of(context).pop();
            }),
            Offstage(
              offstage: !cancelAble && cancelCallBack == null,
              child: _YFlatButton(
                Text(negTitle, style: const TextStyle(color: Colors.black)),
                onClick: cancelCallBack != null
                    ? () {
                        cancelCallBack();
                        Navigator.of(context).pop();
                      }
                    : () {
                        Navigator.of(context).pop();
                      },
              ),
            ),
          ],
        ),
      );
    },
  );
}