selectDocument method

Future<String?> selectDocument({
  1. List<String>? allowedExtensions,
})

Implementation

Future<String?> selectDocument({List<String>? allowedExtensions}) async {
  // if (!(await UFUtils.permissionUtils.getStoragePermission())) {
  //   await permissionDeniedDialogue();
  //   return null;
  // }

  // Pick a file with allowed extensions
  FilePickerResult? result = await FilePicker.pickFiles(
    type: FileType.custom,
    allowedExtensions:
        allowedExtensions ??
        [
          'pdf',
          'doc',
          'docx',
          // 'xls',
          // 'xlsx',
          'png',
          'jpg',
          'jpeg',
        ], // Add your desired extensions
  );

  String? filePath;
  if (result != null) {
    filePath = result.files.single.path;
  } else {
    filePath = null;
  }
  return filePath;
}