import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; class CustomDialogWidget extends StatefulWidget { CustomDialogWidget({ super.key, required this.title, required this.content, required this.onConfirm, String? confirmText, }) : confirmText = confirmText ?? '确认'.tr; final String title; final Widget content; final VoidCallback onConfirm; final String confirmText; @override State createState() => _CustomDialogWidgetState(); } class _CustomDialogWidgetState extends State { @override Widget build(BuildContext context) { return Dialog( backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(14.r), // 圆角 ), child: Column( mainAxisSize: MainAxisSize.min, children: [ SizedBox(height: 18.h), Text( widget.title, style: TextStyle( fontSize: 18.sp, fontWeight: FontWeight.bold, ), ), SizedBox(height: 10.h), widget.content, SizedBox(height: 10.h), Container( decoration: const BoxDecoration( border: Border( top: BorderSide( color: Colors.grey, // 右侧边框颜色 width: 0.5, // 右侧边框宽度 ), ), ), child: Row( children: [ Expanded( // 左侧文本占一半 child: GestureDetector( onTap: () { Get.back(); }, child: Container( alignment: Alignment.center, height: 42.h, decoration: const BoxDecoration( border: Border( right: BorderSide( color: Colors.grey, // 右侧边框颜色 width: 0.5, // 右侧边框宽度 ), ), ), child: Text( '取消'.tr, textAlign: TextAlign.center, style: TextStyle(fontSize: 14.sp, color: Colors.grey), ), ), ), ), Expanded( // 右侧文本占一半 child: GestureDetector( onTap: () { Get.back(); widget.onConfirm(); }, child: Container( alignment: Alignment.center, height: 42.h, child: Text( widget.confirmText, textAlign: TextAlign.center, style: TextStyle( fontSize: 14.sp, color: Colors.blue, fontWeight: FontWeight.w600, ), ), ), ), ), ], ), ) ], ), ); } }