我正在使用ImagePicker
实现个人资料图片上传,并将逻辑放入按钮的onPressed
函数中,如下所示:
OutlinedButton.icon(
icon: Icon(Icons.upload),
label: Text("Select profile picture"),
onPressed: () async {
XFile? image = await introVM.imagePicker.pickImage(
source: ImageSource.gallery,
imageQuality: 50,
preferredCameraDevice: CameraDevice.front);
if (image != null) introVM.setProfilePicture(image!.path);
},
);
一切运行正常,没有错误,但我收到了关于async
部分的LINT警告:
应为同步函数,但获得了异步.
我做错了吗?