import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:flutter/material.dart'; void showAwesomeDialog({ required BuildContext context, required Widget body, required VoidCallback onOk, required VoidCallback onCancel, }) { AwesomeDialog( context: context, dialogType: DialogType.noHeader, animType: AnimType.scale, body: body, dialogBackgroundColor: Theme.of(context).colorScheme.surfaceContainer, btnOkText: "确认", btnCancelText: "取消", btnOkColor: Colors.orange, btnCancelColor: Colors.grey, buttonsBorderRadius: BorderRadius.circular(10), headerAnimationLoop: false, dismissOnTouchOutside: false, dismissOnBackKeyPress: true, btnOk: ElevatedButton( onPressed: onOk, style: ElevatedButton.styleFrom( elevation: 0, backgroundColor: Theme.of(context).colorScheme.primary, foregroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.symmetric(horizontal: 20, vertical: 6), textStyle: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, fontFamily: 'CustomFont'), ), child: Text("确认"), ), btnCancelOnPress: onCancel, ).show(); } // 显示成功提示 void showSuccessDialog(BuildContext context, String message) { AwesomeDialog( context: context, dialogType: DialogType.success, animType: AnimType.scale, title: message, btnOkText: "好的", btnOkColor: Colors.green, btnOkOnPress: () {}, autoHide: Duration(seconds: 2), ).show(); } // 显示失败提示 void showErrorDialog(BuildContext context, String message) { AwesomeDialog( context: context, dialogType: DialogType.error, animType: AnimType.scale, title: message, btnOkText: "好的", btnOkColor: Colors.red, btnOkOnPress: () {}, autoHide: Duration(seconds: 2), ).show(); }