导入依赖
# Toast库
fluttertoast: ^8.0.9
工具类
import 'dart:ui';
import 'package:fluttertoast/fluttertoast.dart';
///吐司工具类
class ToastUtil {
///显示吐司
static showToast(
{required String msg,
double? fontSize,
ToastGravity? gravity,
Color? backgroundColor,
Color? textColor}) {
Fluttertoast.showToast(msg: msg);
}
}
使用案列
ToastUtil.showToast(msg: result.msg ?? "");