伙计们,我正在使用 ImagePicker
插件访问我的应用程序中的图像,但是如果我决定取消它,我会收到此错误 NoSuchMethodError: The getter 'path' was called on null
。关于如何修复它的任何想法?
这是我的ImagePicker
:
FlatButton(
onPressed: () async {
final PickedFile file =
await picker.getImage(source: ImageSource.camera);
editImage(file.path);
},
child: Text('Câmera'),
),
答案 0 :(得分:0)
修复:
FlatButton(
onPressed: () async {
final PickedFile file =
await picker.getImage(source: ImageSource.camera);
if (file != null) {
editImage(file.path);
}
},
child: Text('Câmera'),
),