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,
    2. int messageCode
    )?,
  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,
})

function file picker options

Implementation

static filePickerOptions(
    {required BuildContext context,
    required FileData fileData,
    required FileMode fileMode,
    required Function(FileData fileData) onSelected,
    Function(String message, int messageCode)? onCancel,
    bool crop = false,
    int? maxFileSizeInMB,
    bool cropOnlySquare = false,
    String cropperToolbarTitle = Files.cropperToolbarTitle,
    Color cropperToolbarColor = Files.cropperToolbarColor,
    Color cropperToolbarWidgetsColor = Files.cropperToolbarWidgetsColor,
    List<String>? allowedExtensions}) 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, messageCode) {
            if (onCancel != null) {
              onCancel(message, messageCode);
            }
          })
      : 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, messageCode) {
                if (onCancel != null) {
                  onCancel(message, messageCode);
                }
              })
          : await Files.filePicker(
              fileData: fileData,
              maxFileSizeInMb: maxFileSizeInMB,
              allowedExtensions: allowedExtensions,
              onSelected: (fileData) {
                onSelected(fileData);
              },
              onCancel: (message, messageCode) {
                if (onCancel != null) {
                  onCancel(message, messageCode);
                }
              });
}