import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:fluttertoast/fluttertoast.dart'; /// Toast 工具类(封装 fluttertoast + EasyLoading) class Toast { Toast._(); /// 短提示(屏幕底部) static void show(String message) { if (message.isEmpty) return; Fluttertoast.showToast( msg: message, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 2, backgroundColor: const Color(0xCC000000), textColor: Colors.white, fontSize: 14, ); } /// 成功样式(顶部绿色弹条) static void success(String message) { if (message.isEmpty) return; EasyLoading.showSuccess(message, duration: const Duration(seconds: 2)); } /// 失败样式 static void error(String message) { if (message.isEmpty) return; EasyLoading.showError(message, duration: const Duration(seconds: 2)); } /// 警告 static void warn(String message) { if (message.isEmpty) return; EasyLoading.showInfo(message, duration: const Duration(seconds: 2)); } /// Loading static void loading(String message) { EasyLoading.show(status: message); } static void dismiss() => EasyLoading.dismiss(); }