uploadFrom method

Future<String?> uploadFrom({
  1. required BuildContext context,
  2. required ImageSource? source,
  3. dynamic progress(
    1. double
    )?,
  4. Function? complete,
  5. int compressQuality = 80,
  6. String? saveAs,
  7. String? type,
  8. double maxHeight = 1024,
  9. double maxWidth = 1024,
})

Call this if method of uploading (like, from camera) is already known.

source can be SourceType.photoGallery, SourceType.photoCamera, SourceType.videoGallery, SourceType.videoCamera, SourceType.file may return null if source is invalid.

Implementation

Future<String?> uploadFrom({
  required BuildContext context,
  required ImageSource? source,
  Function(double)? progress,
  Function? complete,
  int compressQuality = 80,
  String? saveAs,
  String? type,
  double maxHeight = 1024,
  double maxWidth = 1024,
}) async {
  if (source == null) return null;
  String? path = await getFilePathFromPicker(
    context: context,
    source: source,
    maxHeight: maxHeight,
    maxWidth: maxWidth,
  );
  if (path == null) return null;
  return await uploadFile(
    path: path,
    saveAs: saveAs,
    progress: progress,
    complete: complete,
    compressQuality: compressQuality,
    type: type,
  );
}