Flutter fluttertoast 的参数说明

7 min read
Fluttertoast.showToast(
        msg: "This is Center Short Toast",
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.CENTER,
        timeInSecForIosWeb: 1,
        backgroundColor: Colors.red,
        textColor: Colors.white,
        fontSize: 16.0
    );

Fluttertoast.showToast 方法的参数说明表格:

属性 描述 默认值
msg 显示的文本消息(必需) 无默认值,必填
toastLength Toast 持续时间(短或长)(可选) Toast.LENGTH_SHORT
gravity Toast 位置(顶部、中心或底部)(仅 Web 支持顶部和底部) ToastGravity.BOTTOM
timeInSecForIosWeb iOS 和 Web 的持续时间(以秒为单位) 1(秒)
backgroundColor 背景颜色(可选) null
textColor 文本颜色(可选) null
fontSize 字体大小(可选,浮点数) null
webShowClose Web 是否显示关闭按钮(可选,布尔值) false
webBgColor Web 背景颜色(十六进制颜色字符串) linear-gradient(to right, #00b09b, #96c93d)
webPosition Web 位置(左侧、中心或右侧)(可选) right