如何在颤动中显示自定义吐司对话框?

问题描述 投票:1回答:1

我想展示一个自定义的toast(我自己的小部件布局)。我知道如何展示自定义alert dialogue,但这不是我想要的。

因为,Alert dialogue

  1. 有黑色背景
  2. 当它显示时防止接触
  3. 必须手动解雇

我不想使用flutter toast库,因为我无法使用它创建自定义布局。

我希望在所有其他小部件之上显示我自己的布局,并在一段时间后使其消失。此外,它不应该在显示时阻止任何输入。

dart flutter flutter-layout flutter-animation
1个回答
1
投票

您可以添加this library来添加和自定义您自己的祝酒词。

Widget widget = Center(
      child: ClipRRect(
        borderRadius: BorderRadius.circular(30.0),
        child: Container(
          width: 40.0,
          height: 40.0,
           color: Colors.grey.withOpacity(0.3),
          child: Icon(
            Icons.add,
            size: 30.0,
            color: Colors.green,
          ),
        ),
      ),
    );

    ToastFuture toastFuture = showToastWidget(
      widget,
      duration: Duration(seconds: 3),
      onDismiss: () {
        print("the toast dismiss"); // the method will be called on toast dismiss.
      },
    );
© www.soinside.com 2019 - 2024. All rights reserved.