我有{_1}},名称为_pickedImage。
我遇到句柄File.path null的问题,我已经使用以下代码处理File
null:
path
或
if (pickedImage.path == null)
每次我按下按钮时,我都无法处理File.path if (pickedImage.path.isEmpty)
,并且收到此错误。
null
我做错了吗?
答案 0 :(得分:1)
$ ansible --version
ansible 2.3.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
错误仅是因为您试图从═══════ Exception caught by gesture ═══════════════════════════════════════════
The following NoSuchMethodError was thrown while handling a gesture:
The getter 'path' was called on null.
Receiver: null
Tried calling: path
获取路径。
在调用下一个代码之前,您需要检查文件是否为空:
null File
答案 1 :(得分:0)
看起来变量pickedImage
本身为空。
尝试这样
if(pickedImage?.path?.isEmpty != false)
或
if(pickedImage == null || pickedImage.path == null || pickedImage.path.isEmpty)