show static method

void show(
  1. String msg, {
  2. Toast? toastLength = Toast.LENGTH_SHORT,
  3. int timeInSecForIosWeb = 1,
  4. ToastGravity? gravity = ToastGravity.CENTER,
  5. Color? backgroundColor = Colors.grey,
  6. Color? textColor = Colors.white,
  7. double? fontSize = 16,
})

使用默认toast msg内容 toastLength显示时长 timeInSecForIosWeb gravity弹出位置 backgroundColor背景色 textColor文字颜色 fontSize文字大小

Implementation

static void show(
  String msg, {
  Toast? toastLength = Toast.LENGTH_SHORT,
  int timeInSecForIosWeb = 1,
  ToastGravity? gravity = ToastGravity.CENTER,
  Color? backgroundColor = Colors.grey,
  Color? textColor = Colors.white,
  double? fontSize = 16,
}) {
  Fluttertoast.cancel();
  Fluttertoast.showToast(
    msg: msg,
    toastLength: toastLength,
    // 持续时间
    gravity: gravity,
    // 显示位置
    timeInSecForIosWeb: timeInSecForIosWeb,
    // 仅适用于iOS和Web
    backgroundColor: backgroundColor,
    // 背景颜色
    textColor: textColor,
    // 文本颜色
    fontSize: fontSize, // 字体大小
  );
}