show method

void show(
  1. String msg, {
  2. ToastGravity gravity = ToastGravity.BOTTOM,
  3. ToastDuration duration = ToastDuration.LONG,
})

显示toast提示 msg 提示内容 gravity 显示位置(即对齐方式) duration 显示

Implementation

void show(String msg, {ToastGravity gravity = ToastGravity.BOTTOM, ToastDuration duration = ToastDuration.LONG}) {
  showToastWidget(
    Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        Container(
          padding: EdgeInsets.only(left: 16, top: 10, right: 16, bottom: 10),
          margin: EdgeInsets.only(left: 20, right: 20, bottom: gravity == ToastGravity.BOTTOM ? 60 : 0),
          decoration: BoxDecoration(
            color: Color(0xe63B372C),
            borderRadius: BorderRadius.all(Radius.circular(8)),
          ),
          constraints: BoxConstraints(
            minHeight: 38,
            maxWidth: MediaUtils.instance.screenWidth - 40,
          ),
          child: Text(
            msg,
            style: TextStyle(color: Color(0xffFCF7EB), fontSize: 12),
            softWrap: true,
            maxLines: 10,
            textAlign: TextAlign.justify,
          ),
        ),
      ],
    ),
    position: gravity == ToastGravity.BOTTOM ? ToastPosition.bottom : ToastPosition.center,
    duration: duration == ToastDuration.LONG ? Duration(milliseconds: 1500) : Duration(milliseconds: 1000),
    handleTouch: false,
  );
}