操作数可以为null,因此条件始终是正确的。删除条件
我不断收到此警告,我不确定如何解决。如果您可以的话,请帮助 以下是代码的摘录
String imageUrl = '';
CircleAvatar(
backgroundColor: Colors.white70,
backgroundImage: imageUrl != null
? Image.network(imageUrl).image
: AssetImage(ProjectImages.placeholder),
minRadius: 50.0,
),
I keep getting this warning and I am unsure how to resolve it. Help if u can please
Below is the excerpt of the code
String imageUrl = '';
CircleAvatar(
backgroundColor: Colors.white70,
backgroundImage: imageUrl != null
? Image.network(imageUrl).image
: AssetImage(ProjectImages.placeholder),
minRadius: 50.0,
),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您之所以会得到此警告,是因为您正在声明带有和空字符串的变量“ imageUrl” 。
注意:空字符串和空物都不相同。因此,要摆脱此警告,您必须使您的可变无效
您的警告将消失:)
You are getting this warning because you are declaring your variable "imageUrl" with and empty String.
Note: Empty string and null both are not same they are different. So, to get rid of this warning you have to make your variable nullable like this
Your warning will be gone :)