gpt4 book ai didi

flutter - 如何在 flutter 中发出可关闭的警报?

转载 作者:行者123 更新时间:2023-12-04 07:34:36 30 4
gpt4 key购买 nike

我可以显示警报,但无法关闭它。但为什么?
编码:

showGeneralDialog(
barrierColor: Colors.red,
context: context,
barrierDismissible: true,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
transitionDuration: const Duration(milliseconds: 300),
pageBuilder: (BuildContext buildContext, Animation animation,
Animation secondaryAnimation) {
if (shouldDismiss) {
Future.delayed(const Duration(seconds: 3), () {
Navigator.of(context, rootNavigator: true).pop(true);
});
}
return SomeWidget();

最佳答案

替换这个

 Navigator.of(context, rootNavigator: true).pop(true);
这样
 Navigator.of(buildContext, rootNavigator: true).pop(true);

关于flutter - 如何在 flutter 中发出可关闭的警报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67796505/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com