compressAndGetFile static method

Future<File?> compressAndGetFile(
  1. File file, {
  2. int quality = 10,
})

Implementation

static Future<File?> compressAndGetFile(File file, {int quality = 10}) async {
  final fileSample = File(
      '${(await getTemporaryDirectory()).path}/fotoSample${DateTime.now().microsecondsSinceEpoch}.jpg');

  var result = await FlutterImageCompress.compressAndGetFile(
    file.absolute.path,
    fileSample.path,
    quality: quality,
  );
  File? file2;
  if (result != null) {
    file2 = File(result.path);
  } else {
    file2 = file;
  }
  return file2;
}