是否有任何方法可以根据条件打开一个带有选择列表的警报对话框?

发布于 2025-02-09 19:50:51 字数 179 浏览 3 评论 0原文

因此,基本上我有一个倒计时计时器一分钟,当分钟完成时,我希望一个警报对话框在屏幕上弹出用户:

if (isCompleted) {
      //open the dialog widget here
}

我找不到解决方案。我只找到可以在按钮上打开对话框的解决方案。 谁能帮忙?

So basically I have a countdown timer for a minute and when the minute finishes I want an alert dialog to pop on the screen for the user e.g:

if (isCompleted) {
      //open the dialog widget here
}

I can't find solutions for that. I'm only finding solutions that opens the dialog on button press.
Can anyone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韬韬不绝 2025-02-16 19:50:51

我在第一次打开应用程序时在我的项目中使用此信息来显示信息对话框:

Future.delayed(Duration(milliseconds: 500), () {
                            showDialog(
                              context: context,
                              builder: (context) => AlertDialog(
                                       //etc
                                )

您可能可以将小部件包装在futurebuilder中(因此您可以访问context )将您的倒计时作为future参数,并且,当倒计时结束时,您可以从那里调用showdialog

I used this in a project of mine to display an info dialog when opening the app for the first time:

Future.delayed(Duration(milliseconds: 500), () {
                            showDialog(
                              context: context,
                              builder: (context) => AlertDialog(
                                       //etc
                                )

You can probably wrap your widgets in a FutureBuilder (so you have access to context) with your countdown as the future argument, and, when the countdown is over, you can call showDialog from there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文