I am implementing a profile picture upload with ImagePicker
and put the logic into the onPressed
function of a button like this:
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);
},
);
Everything works fine without errors, but I am getting a lint warning about the async
part:
Expected a sync function but got async.
Am I doing it wrong?