我有这个对话框,但是当我调用它时,它给了我这个错误:未处理的异常:'package:flutter / src / widgets / localizations.dart':失败的断言:453行pos 12:'context!= null':不正确。,我的代码:
return showDialog(
context: context,
child: AlertDialog(
title: Text(title),
content: Text(msg),
actions: [cancel, ok],
),
);
错误消息会告诉您确切的问题所在:您的变量context
是null
。
您需要提供一个context
非空值。
您还应该提供builder
而不是child
,因为出于充分的理由不赞成使用这种方式来建立对话框。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句