makeText static method

Toast makeText({
  1. required BuildContext context,
  2. String? content,
  3. Color? contentColor,
  4. int duration = -1,
  5. Color? backgroundColor,
  6. double? top,
  7. String? toastPosition,
  8. int animated = 0,
  9. Widget? child,
})

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();
}