resizeUploadFileParent static method

Future<String> resizeUploadFileParent(
  1. File file,
  2. String tableName,
  3. int id,
  4. String fieldName, {
  5. String fileName = '',
  6. int targetWidth = 300,
  7. int quality = 80,
})

Implementation

static Future<String> resizeUploadFileParent(
  File file,
  String tableName,
  int id,
  String fieldName, {
  String fileName = '',
  int targetWidth = 300,
  int quality = 80,
}) async {
  ImageProperties properties =
      await FlutterNativeImage.getImageProperties(file.path);
  File compressedFile = await FlutterNativeImage.compressImage(file.path,
      quality: quality,
      targetWidth: targetWidth,
      targetHeight:
          ((properties.height ?? 1) * targetWidth / (properties.width ?? 1))
              .round());

  return await uploadFileParent(compressedFile, tableName, id, fieldName,
      fileName: fileName);
}