Flutter 如何更改flatter中的空字值?
我从json文件导入数据,如果number\u phone的值为空或null,如何用No phone number替换null word? 我的代码:Flutter 如何更改flatter中的空字值?,flutter,dart,null,Flutter,Dart,Null,我从json文件导入数据,如果number\u phone的值为空或null,如何用No phone number替换null word? 我的代码: 图像解释当没有电话号码时的空单词为空或为空。重要提示:下面的代码可以帮助您 '${number_phone.isEmpty ? '' : number_phone}' '${number_phone ?? ''}' 第一行表示空,第二行表示空 电话号码没有电话号码“ 或: number_phone==null | | number_phone=
图像解释当没有电话号码时的空单词为空或为空。重要提示:下面的代码可以帮助您
'${number_phone.isEmpty ? '' : number_phone}'
'${number_phone ?? ''}'
第一行表示空,第二行表示空 电话号码没有电话号码“ 或:
number_phone==null | | number_phone==''没有电话号码“:”$number\u phone“,
最后我修复了它,只需添加??”json指令中没有电话,如下所示:
“${data[i][“téléphone”]??“No phone”}”不工作始终我收到null这个词如果json文件中没有号码phone,我想用“pas de téléphone”替换null不工作始终我收到null这个词如果json文件中没有号码phone,我想用'pas de téléphone'@替换null。你确定你没有在
number\u phone
中使用'${'
吗?我也尝试过,如果我没有使用'${'
包装number\u phone
,效果很好。如果仍然不起作用,也许你可以打印(number\u phone)
并向我们显示结果。谢谢,但不再工作,我在我的帖子中添加了更多信息
'${number_phone.isEmpty ? '' : number_phone}'
'${number_phone ?? ''}'