showConfirm<T> static method
Future<T?>
showConfirm<T>({
- Widget? child,
- String? title,
- String? content,
- String? leftBtnText,
- String? rightBtnText,
- VoidCallback? onLeftTap,
- VoidCallback? onRightTap,
- bool showClose = true,
- bool dismissOnTouch = true,
- Color? leftBtnBg,
- Color? rightBtnBg,
- Color? rightBtnColor,
- Color? contentColor,
- bool dismissOnBackPressed = true,
- Color? bgColor,
- double? radius,
- bool showCancelBtn = true,
- double? width,
显示确认信息对话框
Implementation
static Future<T?> showConfirm<T>({Widget? child, String? title, String? content,
String? leftBtnText, String? rightBtnText, VoidCallback? onLeftTap, VoidCallback? onRightTap,
bool showClose = true, bool dismissOnTouch = true, Color? leftBtnBg, Color? rightBtnBg, Color? rightBtnColor,
Color? contentColor, bool dismissOnBackPressed = true, Color? bgColor, double? radius,
bool showCancelBtn = true, double? width}) async {
Color textColor = Theme.of(Get.context!).textTheme.bodyLarge?.color ?? Colors.black87;
Widget c = child ?? Padding(padding: const EdgeInsets.only(top: 15, bottom: 25,
left: 20, right: 20),
child: Text(content??"", textAlign: TextAlign.center, style:
TextStyle(color: textColor, fontSize: 16)),);
return await showCenter<T>(Stack(children: [
Column(crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 15,),
if(title!=null)Text(title, textAlign: TextAlign.center, style: TextStyle(color:contentColor?? Theme.of(Get.context!).textTheme.titleLarge!.color!,
fontSize: 18, fontWeight: FontWeight.w600),),
c,
const Divider(height: 1, color: Color(0x11000000),),
Row(mainAxisSize: MainAxisSize.max, children: [
if(showCancelBtn)Expanded(child: SuperText(leftBtnText ?? "取消", expand: true,
bgColor: leftBtnBg , style: TextStyle(color: textColor.withOpacity(0.6), fontSize: 16),
height: 50, onTap: onLeftTap ?? ()=> Get.back(result: false))),
if(showCancelBtn)Container(height: 50, width: 1, color: Theme.of(Get.context!).dividerColor,),
Expanded(child: SuperText(rightBtnText ?? "确定", expand: true,
bgColor: rightBtnBg , style: TextStyle(color: rightBtnColor ?? textColor, fontSize: 16),
height: 50, onTap: onRightTap ?? ()=> Get.back(result: true),
))
],
)
],
),
if (showClose)Positioned(right: 3,child: IconButton(onPressed: ()=> Get.back(), icon: const Icon(Icons.close,
size: 24,)),)
],),
dismissOnBackPressed: dismissOnBackPressed, dismissOnTouch: dismissOnTouch,
bgColor: bgColor, radius: radius, width: 340, padding: EdgeInsets.symmetric(horizontal: (Get.width-340)/2));
}