filePickerOptions static method

dynamic filePickerOptions({
  1. required BuildContext context,
  2. required FileData fileData,
  3. required FileMode fileMode,
  4. required dynamic onSelected(
    1. FileData fileData
    ),
  5. dynamic onCancel(
    1. String message
    )?,
  6. bool crop = false,
  7. int? maxFileSizeInMB,
  8. bool cropOnlySquare = false,
  9. String cropperToolbarTitle = Files.cropperToolbarTitle,
  10. Color cropperToolbarColor = Files.cropperToolbarColor,
  11. Color cropperToolbarWidgetsColor = Files.cropperToolbarWidgetsColor,
  12. List<String> allowedExtensions = Files.allowedAllExtensions,
})

function file picker options

Implementation

static filePickerOptions(
    {required BuildContext context,
    required FileData fileData,
    required FileMode fileMode,
    required Function(FileData fileData) onSelected,
    Function(String message)? onCancel,
    bool crop = false,
    int? maxFileSizeInMB,
    bool cropOnlySquare = false,
    String cropperToolbarTitle = Files.cropperToolbarTitle,
    Color cropperToolbarColor = Files.cropperToolbarColor,
    Color cropperToolbarWidgetsColor = Files.cropperToolbarWidgetsColor,
    List<String> allowedExtensions = Files.allowedAllExtensions}) async {
  fileMode == FileMode.camera
      ? await Files.cameraPicker(
          fileData: fileData,
          crop: crop,
          maxFileSizeInMb: maxFileSizeInMB,
          cropOnlySquare: cropOnlySquare,
          cropperToolbarTitle: cropperToolbarTitle,
          cropperToolbarColor: cropperToolbarColor,
          cropperToolbarWidgetsColor: cropperToolbarWidgetsColor,
          onSelected: (fileData) {
            onSelected(fileData);
          },
          onCancel: (message) {
            if (onCancel != null) {
              onCancel(message);
            }
          })
      : fileMode == FileMode.gallery
          ? await Files.imagePicker(
              fileData: fileData,
              crop: crop,
              maxFileSizeInMb: maxFileSizeInMB,
              cropOnlySquare: cropOnlySquare,
              cropperToolbarTitle: cropperToolbarTitle,
              cropperToolbarColor: cropperToolbarColor,
              cropperToolbarWidgetsColor: cropperToolbarWidgetsColor,
              onSelected: (fileData) {
                onSelected(fileData);
              },
              onCancel: (message) {
                if (onCancel != null) {
                  onCancel(message);
                }
              })
          : await Files.filePicker(
              fileData: fileData,
              maxFileSizeInMb: maxFileSizeInMB,
              allowedExtensions: allowedExtensions,
              onSelected: (fileData) {
                onSelected(fileData);
              },
              onCancel: (message) {
                if (onCancel != null) {
                  onCancel(message);
                }
              });
}