makeText static method
Implementation
static Toast makeText({
required BuildContext context,
String? content, //文本内容
Color? contentColor, //字体颜色
int duration = -1, // 显示时间
Color? backgroundColor, //背景
double? top, // 与上边 边距 距离
String? toastPosition,
int animated = 0, // 动画, 默认透明/不透明
Widget? child, //自定义的 Toast
}) {
_toastPosition = toastPosition ?? 'center';
if (content == null && child == null) {
content = '未知...';
}
_context = context;
_content = content;
if (contentColor != null) {
_contentColor = contentColor;
}
_milliseconds = duration <= LENGTH_SHORT ? SHORT : LONG;
if (backgroundColor != null) {
_backgroundColor = backgroundColor;
}
_animated = animated;
if (child != null) {
_toastWidget = child;
} else {
_toastWidget = _defaultToastLayout();
}
return Toast();
}