pickReceipt method
Implementation
void pickReceipt() async {
if (receiptFile.value != null) {
CustomFlashWidget.showFlashMessage(
type: FlashType.error,
title: "Invalid upload",
message: "You can only upload a single file",
);
return;
}
try {
loadingDialog();
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['pdf', 'jpg', 'jpeg', 'png'],
);
if (result != null) {
String extension = p.extension(result.xFiles.first.name);
log('Path ${result.xFiles.first.path} Extension $extension');
receiptFile.value = result.xFiles.first;
uploadReceipt();
}
} catch (e) {
log('Error picking photo : ${e.toString()}');
CustomFlashWidget.showFlashMessage(
type: FlashType.error,
title: 'Error',
message: "Failed to change photo. Please try again.");
}
closeDialog();
}